Class: Chronicle::Models::ModelFactory
- Inherits:
-
Object
- Object
- Chronicle::Models::ModelFactory
- Defined in:
- lib/chronicle/models/model_factory.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(type_id:, properties: []) ⇒ ModelFactory
constructor
A new instance of ModelFactory.
Constructor Details
#initialize(type_id:, properties: []) ⇒ ModelFactory
Returns a new instance of ModelFactory.
6 7 8 9 |
# File 'lib/chronicle/models/model_factory.rb', line 6 def initialize(type_id:, properties: []) @type_id = type_id @properties = properties end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/chronicle/models/model_factory.rb', line 4 def id @id end |
Instance Method Details
#generate ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chronicle/models/model_factory.rb', line 11 def generate attribute_info = @properties.map do |property| generate_attribute_info(property) end type_id = @type_id Class.new(Chronicle::Models::Base) do attribute_info.each do |a| attribute(a[:name], a[:type]) end @type_id = type_id end end |