Module: MarkMapper::Plugins::Rails::ClassMethods

Defined in:
lib/mark_mapper/plugins/rails.rb

Instance Method Summary collapse

Instance Method Details

#column_namesObject


58
59
60
# File 'lib/mark_mapper/plugins/rails.rb', line 58

def column_names
  unaliased_keys.keys
end

#create_accessors_for(key) ⇒ Object


69
70
71
72
73
74
75
# File 'lib/mark_mapper/plugins/rails.rb', line 69

def create_accessors_for(key)
  super do
    define_method "#{key.name}_before_type_cast" do
      read_attribute_before_type_cast key.name
    end
  end
end

#has_many(*args, &extension) ⇒ Object


54
55
56
# File 'lib/mark_mapper/plugins/rails.rb', line 54

def has_many(*args, &extension)
  many(*args, &extension)
end

#has_one(*args) ⇒ Object


50
51
52
# File 'lib/mark_mapper/plugins/rails.rb', line 50

def has_one(*args)
  one(*args)
end

#reflect_on_association(name) ⇒ Object

Returns returns an ActiveRecordAssociationAdapter for an association. This adapter has an API that is a subset of ActiveRecord::Reflection::AssociationReflection. This allows MarkMapper to be used with the association helpers in gems like simple_form and formtastic.


65
66
67
# File 'lib/mark_mapper/plugins/rails.rb', line 65

def reflect_on_association(name)
  ActiveRecordAssociationAdapter.for_association(associations[name]) if associations[name]
end