call_with_params 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,19 +4,19 @@ Call a Proc with an arbitrary number of params. The Proc will only be passed the
4
4
 
5
5
  == Installation
6
6
  Add the following to your Gemfile:
7
- gem 'call_with_procs'
7
+ gem 'call_with_params'
8
8
 
9
- CallWithProcs can be mixed into any class by adding a line:
10
- include CallWithProcs
9
+ CallWithParams can be mixed into any class by adding a line:
10
+ include CallWithParams
11
11
 
12
- It is likely you will want to include CallWithProcs in your views. This can best be accomplished by adding in an initializer:
13
- ActionView::Base.send :include, CallWithProcs
12
+ It is likely you will want to include CallWithParams in your views. This can best be accomplished by adding in an initializer:
13
+ ActionView::Base.send :include, CallWithParams
14
14
 
15
15
  == Sample Usage
16
16
  The best place to demonstrate the usage for CallWithParams is in the view:
17
17
  link_to "My URL", call_with_params(my_url, user)
18
18
 
19
- If url is not a Proc, the link will simply be to the specified "my_url" param. However, if it is a Proc, it will call that Proc with any additional params passed into the call_with_params method.
19
+ If "my_url" is not a Proc, the link will simply be the specified "my_url" param. However, if it is a Proc, it will call that Proc with any additional params passed into the call_with_params method.
20
20
 
21
21
  Suppose, for example, that my_url is a locally defined Proc, such as:
22
22
  <% my_url = Proc.new {|user| admin_user_path(user) } %>
@@ -32,12 +32,13 @@ Notice the Proc only takes the first two arguments that are passed in.
32
32
  Additionally, there is another method in CallWithParams called call_each_hash_value_with_params which can take hash of Procs, and invoke each Procs with the additional params passed into the call_each_hash_value_with_params method.
33
33
 
34
34
  For example:
35
- <%= content_tag :tr, call_each_hash_value_with_params(:id => Proc.new {|user| "user-#{user.id}"}, :class => Proc.new { cycle("even", "odd") }) %>
35
+ <%= content_tag :tr, call_each_hash_value_with_params({:id => Proc.new {|user| "user-#{user.id}"},
36
+ :class => Proc.new { cycle("even", "odd") }}, user) %>
36
37
 
37
38
  Any hash values that are not Procs will not be evaluated as Procs:
38
- <%= content_tag :tr, call_each_hash_value_with_params(:id => Proc.new {|user| "user-#{user.id}"},
39
- :class => Proc.new { cycle("even", "odd") },
40
- :style => "color: red") %>
39
+ <%= content_tag :tr, call_each_hash_value_with_params({:id => Proc.new {|user| "user-#{user.id}"},
40
+ :class => Proc.new { cycle("even", "odd") },
41
+ :style => "color: red" }, user) %>
41
42
 
42
43
  == Contributing to call_with_params
43
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "call_with_params"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Hunter"]
12
- s.date = "2013-08-27"
12
+ s.date = "2013-11-04"
13
13
  s.description = "Call a Proc with an arbitrary number of params. The Proc will only be passed the number of arguments that it takes."
14
14
  s.email = "hunterae@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -12,7 +12,7 @@ module CallWithParams
12
12
  if options.is_a?(Proc)
13
13
  call_with_params(options, *args)
14
14
  else
15
- options.inject({}) { |hash, (k, v)| hash[k] = call_with_params(v, *args); hash}
15
+ options.inject(HashWithIndifferentAccess.new) { |hash, (k, v)| hash[k] = call_with_params(v, *args); hash}
16
16
  end
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: call_with_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-27 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: -2869851844355724304
163
+ hash: 1676391244959728215
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements: