collection-json 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,13 +15,12 @@ module CollectionJSON
15
15
  end
16
16
 
17
17
  def build(params = {})
18
- self.dup.tap do |result|
19
- result.data = result.data.map do |data|
20
- data.select! {|k,v| %w{name value}.include?(k)}
21
- data.value = params[data.name] if params[data.name]
22
- data
23
- end
18
+ data = self.data.inject([]) do |array,data|
19
+ result = data.select {|k,v| %w{name value}.include?(k)}
20
+ result['value'] = params[data.name] if params[data.name]
21
+ result['value'] != nil ? array << result : array
24
22
  end
23
+ self.class.from_hash({data: data})
25
24
  end
26
25
 
27
26
  def to_json(*args)
@@ -1,3 +1,3 @@
1
1
  module CollectionJSON
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collection-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70245348079240 !ruby/object:Gem::Requirement
16
+ requirement: &70121528030920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70245348079240
24
+ version_requirements: *70121528030920
25
25
  description: Lightweight gem for building Collection+JSON responses.
26
26
  email:
27
27
  - sebastian@uprise.co.nz