Module: ValidatesTimeliness::ORM::ActiveRecord::ClassMethods

Defined in:
lib/validates_timeliness/orm/active_record.rb

Instance Method Summary collapse

Instance Method Details

#define_attribute_methodsObject



24
25
26
27
28
# File 'lib/validates_timeliness/orm/active_record.rb', line 24

def define_attribute_methods
  super.tap do |attribute_methods_generated|
    define_timeliness_methods true
  end
end

#timeliness_attribute_timezone_aware?(attr_name) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/validates_timeliness/orm/active_record.rb', line 9

def timeliness_attribute_timezone_aware?(attr_name)
  create_time_zone_conversion_attribute?(attr_name, timeliness_column_for_attribute(attr_name))
end

#timeliness_attribute_type(attr_name) ⇒ Object



13
14
15
# File 'lib/validates_timeliness/orm/active_record.rb', line 13

def timeliness_attribute_type(attr_name)
  timeliness_column_for_attribute(attr_name).type
end

#timeliness_column_for_attribute(attr_name) ⇒ Object



17
18
19
20
21
22
# File 'lib/validates_timeliness/orm/active_record.rb', line 17

def timeliness_column_for_attribute(attr_name)
  columns_hash.fetch(attr_name.to_s) do |attr_name|
    validation_type = _validators[attr_name.to_sym].find {|v| v.kind == :timeliness }.type
    ::ActiveRecord::ConnectionAdapters::Column.new(attr_name, nil, validation_type.to_s)
  end
end