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



2
3
4
# File 'lib/thinking_sphinx/active_record/attribute/values.rb', line 2

def initialize(attribute)
  @attribute = attribute
end

Instance Method Details

#value_for(instance) ⇒ Object



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

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