Class: LucidWorks::Schema::IntegerAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/lucid_works/schema/integer_attribute.rb

Constant Summary

Constants inherited from Attribute

Attribute::ATTRIBUTES_TYPES, Attribute::RESERVED_ATTRIBUTE_NAMES

Instance Attribute Summary

Attributes inherited from Attribute

#name, #origin, #schema, #values

Instance Method Summary collapse

Methods inherited from Attribute

#encode_and_insert, factory, #initialize, #nil_when_blank?, #omit_during_update?, #omit_when_blank?, sanitize_name, #to_select

Constructor Details

This class inherits a constructor from LucidWorks::Schema::Attribute

Instance Method Details

#create_accessors_for_attribute(klass) ⇒ Object

:nodoc:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lucid_works/schema/integer_attribute.rb', line 11

def create_accessors_for_attribute(klass) # :nodoc:
  super

  klass.class_eval <<-EOF, __FILE__, __LINE__+1
    def #{name}=(new_value)
      if new_value.blank? && (self.class.schema[:#{name}].nil_when_blank? ||
                              self.class.schema[:#{name}].omit_when_blank?)
        new_value = nil
      else
        new_value = new_value.to_i
      end
      @attributes[:#{name}] = new_value
    end
  EOF
end

#human_value(value) ⇒ Object



27
28
29
# File 'lib/lucid_works/schema/integer_attribute.rb', line 27

def human_value(value)
  number_with_delimiter(value)
end

#typeObject



7
8
9
# File 'lib/lucid_works/schema/integer_attribute.rb', line 7

def type
  :integer
end