Class: Relix::Index::Accessor

Inherits:
Object
  • Object
show all
Defined in:
lib/relix/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#identifierObject (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