Class: ThinkingSphinx::ActiveRecord::Attribute::Type

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

Constant Summary

UPDATEABLE_TYPES =
[:integer, :timestamp, :boolean, :float]

Instance Method Summary collapse

Constructor Details

#initialize(attribute, model) ⇒ Type



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

def initialize(attribute, model)
  @attribute, @model = attribute, model
end

Instance Method Details

#multi?Boolean



8
9
10
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 8

def multi?
  @multi ||= attribute.options[:multi] || multi_from_associations
end

#timestamp?Boolean



12
13
14
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 12

def timestamp?
  type == :timestamp
end

#typeObject



16
17
18
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 16

def type
  @type ||= attribute.options[:type] || type_from_database
end

#type=(value) ⇒ Object



20
21
22
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 20

def type=(value)
  @type = attribute.options[:type] = value
end

#updateable?Boolean



24
25
26
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 24

def updateable?
  UPDATEABLE_TYPES.include?(type) && single_column_reference?
end