Module: Foobara::CommandPatternImplementation::Concerns::Entities
- Includes:
- Foobara::Concern
- Defined in:
- foobara-0.6.1/projects/entities_plumbing/src/extensions/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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb', line 66 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[0]) else entity_class.load_many(thunks_to_load) end thunks_to_load rescue Entity::NotFoundError => e error_data_path = DataPath.new(e.data_path) error_data_path.prepend!(data_path) error = error_class.for(e.criteria, data_path: error_data_path.to_s) add_input_error(error) halt! end end |
#load_records ⇒ Object
TODO: make this work with collections...
95 96 97 98 99 |
# File 'projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb', line 95 def load_records self.class.to_load.each_key do |data_path| load_entities(data_path) end end |