Module: ProjectStore::Entity::Builder
- Included in:
- Base
- Defined in:
- lib/project_store/entity/builder.rb
Instance Attribute Summary collapse
-
#decorators ⇒ Object
Returns the value of attribute decorators.
Instance Method Summary collapse
- #add_decorators(entity) ⇒ Object
- #setup_entity!(entity_name, entity = {}, entity_type = nil) ⇒ Object
Instance Attribute Details
#decorators ⇒ Object
Returns the value of attribute decorators.
6 7 8 |
# File 'lib/project_store/entity/builder.rb', line 6 def decorators @decorators end |
Instance Method Details
#add_decorators(entity) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/project_store/entity/builder.rb', line 19 def add_decorators(entity) [:_default, entity.type].each do |decorator_name| case decorators[decorator_name] when Array decorators[decorator_name] when NilClass [] else [decorators[decorator_name]] end .each do |decorator| entity.extend decorator entity.mandatory_properties.concat decorator.mandatory_properties if decorator.respond_to? :mandatory_properties ProjectStore.logger.debug "Decorated entity '#{entity.name}' with '#{decorator}'" end end end |
#setup_entity!(entity_name, entity = {}, entity_type = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/project_store/entity/builder.rb', line 8 def setup_entity!(entity_name, entity = {}, entity_type = nil) entity.extend ProjectStore::Entity::Base entity.name = entity_name entity.type = entity_type unless entity_type.nil? entity.basic_checks ProjectStore.logger.info "New entity '#{entity.name}' of type '#{entity.type}'." # Adds extra decorator add_decorators entity entity end |