Module: EntityComponents
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/entity_components.rb,
lib/entity_components/railtie.rb,
lib/entity_components/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
Instance Method Details
#initialize_components ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/entity_components.rb', line 17 def initialize_components components.each do |c| variable_name = "@#{c}".to_sym klass = c.camelize.constantize values = attributes["values"] name = c.to_sym define_singleton_method name do instance_variable_get(variable_name) || instance_variable_set(variable_name, klass.new(values[name])) end end end |
#serialize_components ⇒ Object
30 31 32 33 34 35 |
# File 'lib/entity_components.rb', line 30 def serialize_components components.each do |c| name = c.to_sym values[name] = send(name).to_h end end |