Class: Casino::Intersection::Match::Base
- Inherits:
-
Object
- Object
- Casino::Intersection::Match::Base
- Defined in:
- lib/casino/intersection/match/base.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#field ⇒ Object
Returns the value of attribute field.
-
#key ⇒ Object
Returns the value of attribute key.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(document, key, selector, value = nil) ⇒ Base
constructor
A new instance of Base.
- #match_arguments ⇒ Object
- #matcher ⇒ Object
- #matcher_for(class_name) ⇒ Object
- #matchers ⇒ Object
Constructor Details
#initialize(document, key, selector, value = nil) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 |
# File 'lib/casino/intersection/match/base.rb', line 7 def initialize(document, key, selector, value = nil) self.document = document self.field = selector[key] self.key = key self.selector = selector self.value = document_value || value end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
5 6 7 |
# File 'lib/casino/intersection/match/base.rb', line 5 def document @document end |
#field ⇒ Object
Returns the value of attribute field.
5 6 7 |
# File 'lib/casino/intersection/match/base.rb', line 5 def field @field end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/casino/intersection/match/base.rb', line 5 def key @key end |
#selector ⇒ Object
Returns the value of attribute selector.
5 6 7 |
# File 'lib/casino/intersection/match/base.rb', line 5 def selector @selector end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/casino/intersection/match/base.rb', line 5 def value @value end |
Instance Method Details
#evaluate ⇒ Object
15 16 17 |
# File 'lib/casino/intersection/match/base.rb', line 15 def evaluate matcher.evaluate end |
#match_arguments ⇒ Object
19 20 21 |
# File 'lib/casino/intersection/match/base.rb', line 19 def match_arguments [ key, value, document, field ] end |
#matcher ⇒ Object
27 28 29 |
# File 'lib/casino/intersection/match/base.rb', line 27 def matcher matchers.find { |matcher| matcher.eligible? } end |
#matcher_for(class_name) ⇒ Object
31 32 33 34 |
# File 'lib/casino/intersection/match/base.rb', line 31 def matcher_for(class_name) class_name = String(class_name).humanize Match.const_get(class_name).new(*match_arguments) end |
#matchers ⇒ Object
23 24 25 |
# File 'lib/casino/intersection/match/base.rb', line 23 def matchers matcher_classes.map { |class_name| matcher_for class_name } end |