Class: SimpleRecord::Attributes::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_record/attributes.rb

Overview

Holds information about an attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, options = nil) ⇒ Attribute

Returns a new instance of Attribute.



209
210
211
212
# File 'lib/simple_record/attributes.rb', line 209

def initialize(type, options=nil)
    @type = type
    @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



207
208
209
# File 'lib/simple_record/attributes.rb', line 207

def options
  @options
end

#typeObject

Returns the value of attribute type.



207
208
209
# File 'lib/simple_record/attributes.rb', line 207

def type
  @type
end

Instance Method Details

#init_value(value) ⇒ Object



214
215
216
217
218
219
220
221
222
# File 'lib/simple_record/attributes.rb', line 214

def init_value(value)
    return value if value.nil?
    ret = value
    case self.type
        when :int
            ret = value.to_i
    end
    ret
end