ribbon 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +5 -0
- data/lib/ribbon.rb +5 -0
- data/lib/ribbon/version.rb +1 -1
- data/lib/ribbon/wrapper.rb +16 -0
- metadata +3 -9
data/Gemfile
CHANGED
data/lib/ribbon.rb
CHANGED
@@ -96,6 +96,11 @@ class Ribbon < BasicObject
|
|
96
96
|
Wrapper.new ribbon
|
97
97
|
end
|
98
98
|
|
99
|
+
def self.extract_hash_from(ribbon)
|
100
|
+
ribbon = ribbon.ribbon if ::Ribbon.wrapped? ribbon
|
101
|
+
ribbon = ribbon.__hash__ if ::Ribbon.instance? ribbon
|
102
|
+
end
|
103
|
+
|
99
104
|
class << self
|
100
105
|
|
101
106
|
# Wraps a Ribbon instance in a Ribbon::Wrapper.
|
data/lib/ribbon/version.rb
CHANGED
data/lib/ribbon/wrapper.rb
CHANGED
@@ -52,6 +52,22 @@ class Ribbon < BasicObject
|
|
52
52
|
else ribbon end.__send__ method, *args, &block
|
53
53
|
end
|
54
54
|
|
55
|
+
# Merges the hash of this wrapped Ribbon with the given +ribbon+, which can
|
56
|
+
# be a Ribbon::Wrapper, a Ribbon or a hash.
|
57
|
+
#
|
58
|
+
# This method returns a new hash.
|
59
|
+
def merge(ribbon, &block)
|
60
|
+
hash.merge Ribbon.extract_hash_from(ribbon), &block
|
61
|
+
end
|
62
|
+
|
63
|
+
# Merges the hash of this wrapped Ribbon with the given +ribbon+, which can
|
64
|
+
# be a Ribbon::Wrapper, a Ribbon or a hash.
|
65
|
+
#
|
66
|
+
# This method modifies the hash of this wrapped Ribbon.
|
67
|
+
def merge!(ribbon, &block)
|
68
|
+
hash.merge! Ribbon.extract_hash_from(ribbon), &block
|
69
|
+
end
|
70
|
+
|
55
71
|
# Converts the wrapped Ribbon and all Ribbons inside into hashes.
|
56
72
|
def to_hash
|
57
73
|
to_hash_recursive
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ribbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rookie
|
16
|
-
requirement: &
|
16
|
+
requirement: &13625980 !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: *
|
24
|
+
version_requirements: *13625980
|
25
25
|
description: Ruby Object Notation. Inspired by JSON and OpenStruct.
|
26
26
|
email: matheus.a.m.moreira@gmail.com
|
27
27
|
executables: []
|
@@ -52,18 +52,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
hash: 1132984077947899198
|
58
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
56
|
none: false
|
60
57
|
requirements:
|
61
58
|
- - ! '>='
|
62
59
|
- !ruby/object:Gem::Version
|
63
60
|
version: '0'
|
64
|
-
segments:
|
65
|
-
- 0
|
66
|
-
hash: 1132984077947899198
|
67
61
|
requirements: []
|
68
62
|
rubyforge_project:
|
69
63
|
rubygems_version: 1.8.10
|