jQuery/Role/Plugin.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 45 / 45 CC 2 SCAR 2.2
CC
2
Cov
100%
mk_jQuery_method_call
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« jQuery/Plugin/FilamentGrpMenu.pm ↑ Summary jQuery/Plugin/funcliteral.pm »
1 package JavaScript::Framework::jQuery::Role::Plugin;
2  
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use MooseX::Types::Moose qw( Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use JavaScript::Framework::jQuery::Subtypes qw( libraryAssets pluginAssets );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 our $VERSION = '0.05';
11  
12 10 has 'name' => (
13 is => 'ro',
14 isa => Str,
15 required => 1,
16 );
17  
18 10 has 'target_selector' => (
19 is => 'ro',
20 isa => Str,
21 required => 1,
22 );
23  
24 10 requires 'cons_statement';
25  
26 10 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 =head1 NAME
29  
30 JavaScript::Framework::jQuery::Role::Plugin - Moose role for jQuery plugin modules
31  
32 =head1 SYNOPSIS
33  
34 package mypackage;
35  
36 use Moose;
37 with 'JavaScript::Framework::jQuery::Role::Plugin';
38  
39 =head1 DESCRIPTION
40  
41 This Moose role adds common jQuery framework methods and declarations.
42  
43 =cut
44  
45 =head1 METHODS
46  
47 =cut
48  
49 =head2 mk_jQuery_method_call( %params )
50  
51 Example:
52  
53 mk_jQuery_method_call('ul.sf-menu', ['supersubs', [ 'json text' ]], ['superfish', [ 'json text' ]]);
54  
55 =cut
56  
57 11 ▶sub mk_jQuery_method_call {
Subroutine mk_jQuery_method_call: called CC=2 SCAR=6.9
Pod documented
58 11 my $self = shift;
59 11 my $selector = shift;
60 11 my @method = @_;
61  
62 11 my $code = '';
63  
64 11 $code .= qq|\$("${selector}")|;
65  
66 11 for my $m (@method) {
67 11 my $func = $m->[0];
68 11 my @arg = @{$m->[1]};
69 11 my $args;
70 11 $args = join ', ' => @arg;
71 11 $code .= qq|.${func}($args)|;
72 }
73 11 $code .= ';';
74  
75 11 return $code;
76 }
77  
78 10 1;
79  
80 =head1 AUTHOR
81  
82 David P.C. Wollmann E<lt>converter42 at gmail.comE<gt>
83  
84 =head1 COPYRIGHT & LICENSE
85  
86 Copyright 2009 David P.C. Wollmann, all rights reserved.
87  
88 This program is free software; you can redistribute it and/or modify it
89 under the same terms as Perl itself.
90  
« jQuery/Plugin/FilamentGrpMenu.pm ↑ Summary jQuery/Plugin/funcliteral.pm »