Module: SimpleMapper::Attributes::ClassMethods

Defined in:
lib/simple_mapper/attributes.rb

Instance Method Summary collapse

Instance Method Details

#maps(attr, *args, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/simple_mapper/attributes.rb', line 26

def maps(attr, *args, &block)
  if block_given?
    hash = args.last
    args << (hash = {}) unless hash.instance_of? Hash
    mapper = simple_mapper.create_anonymous_mapper(&block)
    hash[:type] ||= mapper
    hash[:mapper] = mapper
  end
  attribute = simple_mapper.create_attribute(attr, *args)
  simple_mapper.install_attribute attr, attribute
end

#simple_mapperObject



22
23
24
# File 'lib/simple_mapper/attributes.rb', line 22

def simple_mapper
  @simple_mapper ||= SimpleMapper::Attributes::Manager.new(self)
end