Module: Foobara::CommandPatternImplementation::Concerns::Entities
- Includes:
- Foobara::Concern
- Included in:
- Foobara::CommandPatternImplementation
- Defined in:
- foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/entities.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #load_entities(data_path) ⇒ Object
-
#load_records ⇒ Object
TODO: make this work with collections…
Methods included from Foobara::Concern
foobara_class_methods_module_for, foobara_concern?, included
Instance Method Details
#load_entities(data_path) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/entities.rb', line 57 def load_entities(data_path) error_class = self.class.to_load_paths_and_error_classes[data_path.to_s] entity_class = error_class.entity_class thunks = DataPath.values_at(data_path, inputs) thunks_to_load = thunks.reject(&:created?) begin # here... filter out created entities... if thunks_to_load.size == 1 entity_class.load(thunks_to_load.first) else entity_class.load_many(thunks_to_load) end thunks_to_load rescue Entity::NotFoundError => e add_runtime_error(error_class.for(e.criteria)) end end |
#load_records ⇒ Object
TODO: make this work with collections…
80 81 82 83 84 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/entities.rb', line 80 def load_records self.class.to_load.each_key do |data_path| load_entities(data_path) end end |