class Traits::Attribute
Attributes
active_record[R]
column_definition[R]
Public Class Methods
new(active_record, column_definition)
click to toggle source
# File lib/traits/attribute.rb, line 29 def initialize(active_record, column_definition) @active_record = active_record @column_definition = column_definition end
Public Instance Methods
association()
click to toggle source
# File lib/traits/attribute.rb, line 59 def association model.associations.first_where(from_key_name: name) end
inspect()
click to toggle source
# File lib/traits/attribute.rb, line 51 def inspect "#{model}##{name}" end
model()
click to toggle source
# File lib/traits/attribute.rb, line 34 def model active_record.traits end
null?()
click to toggle source
# File lib/traits/attribute.rb, line 63 def null? column_definition.null end
regular?()
click to toggle source
TODO Remove this
# File lib/traits/attribute.rb, line 39 def regular? !(key? || inheritance_type? || polymorphic_type? || active_record_timestamp?) end
to_s()
click to toggle source
# File lib/traits/attribute.rb, line 55 def to_s name end
validators()
click to toggle source
# File lib/traits/attribute.rb, line 43 def validators active_record.validators_on(name) end
value_from(model_instance)
click to toggle source
# File lib/traits/attribute.rb, line 47 def value_from(model_instance) model_instance.send(name) end