Class: Linkage::Expectations::Simple
- Inherits:
-
Linkage::Expectation
- Object
- Linkage::Expectation
- Linkage::Expectations::Simple
- Defined in:
- lib/linkage/expectations/simple.rb
Constant Summary collapse
- VALID_OPERATORS =
[:==, :'!=', :>, :<, :>=, :<=]
Instance Attribute Summary collapse
-
#meta_object_1 ⇒ Object
readonly
Returns the value of attribute meta_object_1.
-
#meta_object_2 ⇒ Object
readonly
Returns the value of attribute meta_object_2.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#side ⇒ Symbol
readonly
The dataset this expectation applies to: ‘:lhs` or `:rhs`.
Class Method Summary collapse
-
.create(meta_object_1, meta_object_2, operator) ⇒ Object
Automatically create an expectation type depending on the arguments.
Instance Method Summary collapse
- #decollation_needed? ⇒ Boolean
-
#display_warnings ⇒ Object
Display any warnings about this expectation.
- #exactly! ⇒ Object
-
#initialize(meta_object_1, meta_object_2, operator) ⇒ Simple
constructor
Creates a new Simple.
- #same_except_side?(other) ⇒ Boolean
Methods inherited from Linkage::Expectation
Constructor Details
#initialize(meta_object_1, meta_object_2, operator) ⇒ Simple
Creates a new Simple.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/linkage/expectations/simple.rb', line 45 def initialize(, , operator) @meta_object_1 = @meta_object_2 = @operator = operator if !VALID_OPERATORS.include?(operator) raise ArgumentError, "Invalid operator: #{operator.inspect}" end after_initialize end |
Instance Attribute Details
#meta_object_1 ⇒ Object (readonly)
Returns the value of attribute meta_object_1.
9 10 11 |
# File 'lib/linkage/expectations/simple.rb', line 9 def @meta_object_1 end |
#meta_object_2 ⇒ Object (readonly)
Returns the value of attribute meta_object_2.
9 10 11 |
# File 'lib/linkage/expectations/simple.rb', line 9 def @meta_object_2 end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
9 10 11 |
# File 'lib/linkage/expectations/simple.rb', line 9 def operator @operator end |
#side ⇒ Symbol (readonly)
The dataset this expectation applies to: ‘:lhs` or `:rhs`. This only applies to filter expectations.
7 8 9 |
# File 'lib/linkage/expectations/simple.rb', line 7 def side @side end |
Class Method Details
.create(meta_object_1, meta_object_2, operator) ⇒ Object
Automatically create an expectation type depending on the arguments.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/linkage/expectations/simple.rb', line 18 def self.create(, , operator) klass = if .static? && .static? raise ArgumentError, "An expectation with two static objects is invalid" elsif .static? || .static? Filter elsif .side == .side if !.datasets_equal?() raise ArgumentError, "An expectation with two dynamic objects with the same side but different datasets is invalid" end Filter elsif .objects_equal?() Self elsif .datasets_equal?() Cross else Dual end klass.new(, , operator) end |
Instance Method Details
#decollation_needed? ⇒ Boolean
75 76 77 78 79 80 |
# File 'lib/linkage/expectations/simple.rb', line 75 def decollation_needed? merged_field.ruby_type[:type] == String && ( @meta_object_1.collation != @meta_object_2.collation || @meta_object_1.database_type != @meta_object_2.database_type ) end |
#display_warnings ⇒ Object
Display any warnings about this expectation.
72 73 |
# File 'lib/linkage/expectations/simple.rb', line 72 def display_warnings end |
#exactly! ⇒ Object
64 65 66 67 68 69 |
# File 'lib/linkage/expectations/simple.rb', line 64 def exactly! function_1 = Function['binary'].new(@meta_object_1.object, :dataset => @meta_object_1.dataset) function_2 = Function['binary'].new(@meta_object_2.object, :dataset => @meta_object_2.dataset) @meta_object_1 = MetaObject.new(function_1, @meta_object_1.side) @meta_object_2 = MetaObject.new(function_2, @meta_object_2.side) end |
#same_except_side?(other) ⇒ Boolean
57 58 59 60 61 62 |
# File 'lib/linkage/expectations/simple.rb', line 57 def same_except_side?(other) other.is_a?(Simple) && operator == other.operator && .objects_equal?(other.) && .objects_equal?(other.) end |