Class: ThinkingSphinx::ActiveRecord::Attribute::Values

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/attribute/values.rb

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ Values

Returns a new instance of Values.



4
5
6
# File 'lib/thinking_sphinx/active_record/attribute/values.rb', line 4

def initialize(attribute)
  @attribute = attribute
end

Instance Method Details

#value_for(instance) ⇒ Object



8
9
10
11
12
13
# File 'lib/thinking_sphinx/active_record/attribute/values.rb', line 8

def value_for(instance)
  object = column.__stack.inject(instance) { |object, name|
    object.nil? ? nil : object.send(name)
  }
  object.nil? ? nil : object.send(column.__name)
end