Class: Fiona7::AttributeTypeMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/fiona7/attribute_type_mapper.rb

Overview

This class is used to map from virtual attribute types to real attribute types. For example number to string or referencelist to linklist

Defined Under Namespace

Classes: BuiltInTypeMapper, CustomAttributeTypeMapper

Instance Method Summary collapse

Constructor Details

#initialize(obj_class, source = Fiona7.custom_attribute_types) ⇒ AttributeTypeMapper

Returns a new instance of AttributeTypeMapper.



6
7
8
9
10
# File 'lib/fiona7/attribute_type_mapper.rb', line 6

def initialize(obj_class, source=Fiona7.custom_attribute_types)
  self.custom = CustomAttributeTypeMapper.new(obj_class, source)
  self.built_in = BuiltInTypeMapper.new(obj_class)
  self.obj_class = obj_class
end

Instance Method Details

#call(attribute, virtual_type) ⇒ Object



12
13
14
15
16
17
# File 'lib/fiona7/attribute_type_mapper.rb', line 12

def call(attribute, virtual_type)
  self.validate!(attribute,
    self.custom.call(attribute, virtual_type) ||
    self.built_in.call(attribute, virtual_type)
  )
end