Class: Predicator::Variable
- Inherits:
-
Object
- Object
- Predicator::Variable
- Defined in:
- lib/predicator/variable.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(model, attribute) ⇒ Variable
constructor
A new instance of Variable.
- #value_in(context) ⇒ Object
Constructor Details
#initialize(model, attribute) ⇒ Variable
Returns a new instance of Variable.
5 6 7 8 |
# File 'lib/predicator/variable.rb', line 5 def initialize model, attribute @model = model @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/predicator/variable.rb', line 3 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/predicator/variable.rb', line 3 def model @model end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 23 24 |
# File 'lib/predicator/variable.rb', line 20 def == other other.kind_of?(self.class) && other.model == model && other.attribute == attribute end |
#value_in(context) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/predicator/variable.rb', line 10 def value_in context entity_name = model.to_s entity = context.bindings[entity_name] if entity.nil? raise ArgumentError, "Unknown entity #{entity_name}" else entity.send attribute end end |