Class: ResoTransport::EntityType

Inherits:
Struct
  • Object
show all
Defined in:
lib/reso_transport/entity_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_typeObject

Returns the value of attribute base_type

Returns:

  • (Object)

    the current value of base_type



2
3
4
# File 'lib/reso_transport/entity_type.rb', line 2

def base_type
  @base_type
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/reso_transport/entity_type.rb', line 2

def name
  @name
end

#primary_keyObject

Returns the value of attribute primary_key

Returns:

  • (Object)

    the current value of primary_key



2
3
4
# File 'lib/reso_transport/entity_type.rb', line 2

def primary_key
  @primary_key
end

#schemaObject

Returns the value of attribute schema

Returns:

  • (Object)

    the current value of schema



2
3
4
# File 'lib/reso_transport/entity_type.rb', line 2

def schema
  @schema
end

Class Method Details

.from_stream(args) ⇒ Object



3
4
5
# File 'lib/reso_transport/entity_type.rb', line 3

def self.from_stream(args)
  new(args['Name'], args['BaseType'])
end

Instance Method Details

#enumerationsObject



41
42
43
# File 'lib/reso_transport/entity_type.rb', line 41

def enumerations
  @enumerations ||= []
end


37
38
39
# File 'lib/reso_transport/entity_type.rb', line 37

def navigation_properties
  @navigation_properties ||= []
end


33
34
35
# File 'lib/reso_transport/entity_type.rb', line 33

def navigation_property_map
  @navigation_property_map ||= navigation_properties.each_with_object({}) { |p, hsh| hsh[p.name] = p; }
end

#parse(record) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/reso_transport/entity_type.rb', line 7

def parse(record)
  record.each_pair do |k, v|
    next if v.nil?

    property = property_map[k] || navigation_property_map[k]
    record[k] = property.parse(v) if property
  end
end

#parse_value(record) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/reso_transport/entity_type.rb', line 16

def parse_value(record)
  record.each_pair do |k, v|
    next if v.nil?

    property = property_map[k] || navigation_property_map[k]
    record[k] = property.parse(v) if property
  end
end

#propertiesObject



29
30
31
# File 'lib/reso_transport/entity_type.rb', line 29

def properties
  @properties ||= []
end

#property_mapObject



25
26
27
# File 'lib/reso_transport/entity_type.rb', line 25

def property_map
  @property_map ||= properties.each_with_object({}) { |p, hsh| hsh[p.name] = p; }
end