Module: Tiun::Attributes

Included in:
Tiun
Defined in:
lib/tiun/attributes.rb

Constant Summary collapse

AR_MAP =
{
   "string" => "ActiveModel::Type::String",
   "integer" => "ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer",
   "sequence" => "ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer"
}

Instance Method Summary collapse

Instance Method Details

#attribute_name_for(type) ⇒ Object



10
11
12
# File 'lib/tiun/attributes.rb', line 10

def attribute_name_for type
   type.name.singularize.camelize
end

#attribute_types_for(model) ⇒ Object



14
15
16
17
18
19
# File 'lib/tiun/attributes.rb', line 14

def attribute_types_for model
   setup_if_not

   #binding.pry
   attributes.find {|a| a.name == model.name }
end

#attributesObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/tiun/attributes.rb', line 21

def attributes
   return @attributes if @attributes

   @attributes =
      types.map do |type|
         attribute_name = attribute_name_for(type)

         { name: attribute_name, attribute_map: migration_fields_for(type) }.to_os
      end
end