Class: Fried::Schema::Compare
- Inherits:
-
Object
- Object
- Fried::Schema::Compare
- Includes:
- Typings
- Defined in:
- lib/fried/schema/compare.rb
Overview
Compares two Struct objects, used for sorting and equality
Instance Attribute Summary collapse
-
#get_attribute ⇒ Object
Returns the value of attribute get_attribute.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(schema, struct, other) ⇒ Integer?
Like ‘<=>` sign.
-
#initialize ⇒ Compare
constructor
A new instance of Compare.
Constructor Details
#initialize ⇒ Compare
Returns a new instance of Compare.
14 15 16 |
# File 'lib/fried/schema/compare.rb', line 14 def initialize self.get_attribute = GetAttribute.new end |
Instance Attribute Details
#get_attribute ⇒ Object
Returns the value of attribute get_attribute.
12 13 14 |
# File 'lib/fried/schema/compare.rb', line 12 def get_attribute @get_attribute end |
Class Method Details
.build ⇒ Object
18 19 20 21 22 |
# File 'lib/fried/schema/compare.rb', line 18 def self.build new.tap do |instance| instance.get_attribute = GetAttribute.build end end |
.call(schema, struct, other) ⇒ Object
24 25 26 27 |
# File 'lib/fried/schema/compare.rb', line 24 def self.call(schema, struct, other) instance = build instance.(schema, struct, other) end |
Instance Method Details
#call(schema, struct, other) ⇒ Integer?
Returns like ‘<=>` sign.
33 34 35 36 37 38 39 |
# File 'lib/fried/schema/compare.rb', line 33 def call(schema, struct, other) return nil unless struct.class == other.class return nil unless Is[Struct].valid?(struct) return nil unless Is[Struct].valid?(other) compare(schema, struct, other) end |