Module: OceanDynamo::Basal
- Included in:
- Table
- Defined in:
- lib/ocean-dynamo/basal.rb
Instance Method Summary collapse
-
#<=>(other_object) ⇒ Object
Allows sort on instances.
-
#==(comparison_object) ⇒ Object
(also: #eql?)
The equality comparator.
-
#freeze ⇒ Object
Clone and freeze the attributes hash such that associations are still accessible, even on destroyed records, but cloned models will not be frozen.
-
#frozen? ⇒ Boolean
Returns
true
if the attributes hash has been frozen.
Instance Method Details
#<=>(other_object) ⇒ Object
Allows sort on instances
20 21 22 23 24 |
# File 'lib/ocean-dynamo/basal.rb', line 20 def <=>(other_object) if other_object.is_a?(self.class) self.to_key <=> other_object.to_key end end |
#==(comparison_object) ⇒ Object Also known as: eql?
The equality comparator.
7 8 9 10 11 12 13 |
# File 'lib/ocean-dynamo/basal.rb', line 7 def ==(comparison_object) super || comparison_object.instance_of?(self.class) && hash_key.present? && comparison_object.hash_key == hash_key && (range_key == comparison_object.range_key) end |
#freeze ⇒ Object
Clone and freeze the attributes hash such that associations are still accessible, even on destroyed records, but cloned models will not be frozen.
32 33 34 35 |
# File 'lib/ocean-dynamo/basal.rb', line 32 def freeze @attributes = @attributes.clone.freeze self end |
#frozen? ⇒ Boolean
Returns true
if the attributes hash has been frozen.
41 42 43 |
# File 'lib/ocean-dynamo/basal.rb', line 41 def frozen? @attributes.frozen? end |