Class: Relix::Index::Accessor
- Inherits:
-
Object
- Object
- Relix::Index::Accessor
- Defined in:
- lib/relix/index.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
-
#initialize(name) ⇒ Accessor
constructor
A new instance of Accessor.
- #read(object) ⇒ Object
Constructor Details
#initialize(name) ⇒ Accessor
Returns a new instance of Accessor.
13 14 15 16 17 18 19 20 21 |
# File 'lib/relix/index.rb', line 13 def initialize(name) @accessor = name.to_s if @accessor =~ /^(.+)\?$/ @identifier = $1 @interrogative = true else @identifier = @accessor end end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
12 13 14 |
# File 'lib/relix/index.rb', line 12 def identifier @identifier end |
Instance Method Details
#read(object) ⇒ Object
23 24 25 26 27 |
# File 'lib/relix/index.rb', line 23 def read(object) result = object.send(@accessor) result = !!result if @interrogative result end |