Module: MapWithIndifferentAccess::WrapsCollection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/map_with_indifferent_access/wraps_collection.rb
Instance Attribute Summary collapse
-
#inner_collection ⇒ Object
readonly
The encapsulated collection object.
Instance Method Summary collapse
-
#_frozen? ⇒ Boolean
Returns true when the target object (the wrapper) is frozen.
-
#clear ⇒ Object
Removes all entries from the target's #inner_collection.
-
#empty? ⇒ Boolean
Returns
trueif the collection contains no entries. -
#eql?(other) ⇒ Boolean
Returns
truefor another instance of the same class as the target where the target's #inner_collection is#eql?to the given object's #inner_collection. -
#freeze ⇒ Object
Freezes both the target map and its #inner_collection object.
-
#frozen? ⇒ Boolean
Reflects the frozen-ness of its #inner_collection.
-
#hash ⇒ Fixnum
Compute a hash-code for this collection wrapper.
-
#length ⇒ Fixnum
The number of entries in the collection.
-
#size ⇒ Fixnum
The number of entries in the collection.
-
#taint ⇒ Object
Causes the target's #inner_collection to be tainted.
-
#tainted? ⇒ Boolean
Reflects the tainted-ness of its #inner_collection.
-
#trust ⇒ Object
Causes the target's #inner_collection to be trusted.
-
#untaint ⇒ Object
Causes the target's #inner_collection to be untainted.
-
#untrust ⇒ Object
Causes the target's #inner_collection to be untrusted.
-
#untrusted? ⇒ Boolean
Reflects the untrusted-ness of its #inner_collection.
Instance Attribute Details
#inner_collection ⇒ Object (readonly)
The encapsulated collection object.
10 11 12 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 10 def inner_collection @inner_collection end |
Instance Method Details
#_frozen? ⇒ Boolean
Returns true when the target object (the wrapper) is frozen.
There are some cases in which this returns false when
#frozen? would return true.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 32
|
#clear ⇒ Object
Removes all entries from the target's #inner_collection.
115 116 117 118 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 115 def clear inner_collection.clear self end |
#empty? ⇒ Boolean
Returns true if the collection contains no entries.
Returns false if the collection contains 1 or more
entries.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 24
|
#eql?(other) ⇒ Boolean
Returns true for another instance of the same class as
the target where the target's #inner_collection is
#eql? to the given object's #inner_collection. Returns
false otherwise.
134 135 136 137 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 134 def eql?(other) self.class == other.class && self.inner_collection.eql?( other.inner_collection ) end |
#freeze ⇒ Object
Freezes both the target map and its #inner_collection object.
122 123 124 125 126 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 122 def freeze super inner_collection.freeze self end |
#frozen? ⇒ Boolean
Reflects the frozen-ness of its #inner_collection.
Returns true when the #inner_collection is frozen (
and the target/wrapper might be frozen or not).
Returns false when the #inner_collection is not
frozen (and neither is the target/wrapper).
When the #inner_collection is frozen, but the target object is not, then the target behaves as if frozen in most ways, but some of the restrictions that Ruby applies to truly frozen (such as preventing instance methods from being dynamically added to the object) do not apply.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 56
|
#hash ⇒ Fixnum
Compute a hash-code for this collection wrapper. Two wrappers with the same type and the same #inner_collection content will have the same hash code (and will match using #eql?).
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 82 def_delegators( :inner_collection, :length, :size, :empty?, :tainted?, :untrusted?, :frozen?, :hash, ) |
#length ⇒ Fixnum
The number of entries in the collection.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 12
|
#size ⇒ Fixnum
The number of entries in the collection.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 18
|
#taint ⇒ Object
Causes the target's #inner_collection to be tainted.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 93
|
#tainted? ⇒ Boolean
Reflects the tainted-ness of its #inner_collection.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 48
|
#trust ⇒ Object
Causes the target's #inner_collection to be trusted.
105 106 107 108 109 110 111 112 |
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 105 [:taint, :untaint, :untrust, :trust ].each do |method_name| class_eval " def \#{method_name}\n inner_collection.\#{method_name}\n self\n end\n EOS\nend\n", __FILE__, __LINE__ + 1 |
#untaint ⇒ Object
Causes the target's #inner_collection to be untainted.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 96
|
#untrust ⇒ Object
Causes the target's #inner_collection to be untrusted.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 99
|
#untrusted? ⇒ Boolean
Reflects the untrusted-ness of its #inner_collection.
|
|
# File 'lib/map_with_indifferent_access/wraps_collection.rb', line 52
|