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

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(attribute, model) ⇒ Type

Returns a new instance of Type.



6
7
8
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 6

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

Instance Method Details

#multi?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 10

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

#timestamp?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 14

def timestamp?
  type == :timestamp
end

#typeObject



18
19
20
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 18

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

#type=(value) ⇒ Object



22
23
24
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 22

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

#updateable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/thinking_sphinx/active_record/attribute/type.rb', line 26

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