Class: RESTfulLoaders::CardTypesPropertyDefinitionsLoader
- Inherits:
-
Object
- Object
- RESTfulLoaders::CardTypesPropertyDefinitionsLoader
- Includes:
- LoaderHelper
- Defined in:
- lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_property_definitions_loader.rb
Instance Method Summary collapse
-
#initialize(project, params) ⇒ CardTypesPropertyDefinitionsLoader
constructor
A new instance of CardTypesPropertyDefinitionsLoader.
- #load ⇒ Object
Methods included from LoaderHelper
Constructor Details
#initialize(project, params) ⇒ CardTypesPropertyDefinitionsLoader
Returns a new instance of CardTypesPropertyDefinitionsLoader.
6 7 8 9 |
# File 'lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_property_definitions_loader.rb', line 6 def initialize(project, params) @project = project @params = params end |
Instance Method Details
#load ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_property_definitions_loader.rb', line 11 def load mappings = extract('card_types', @project).collect do |card_type| mapping = card_type['card_types_property_definitions'].values end.flatten pds = extract('property_definitions', @project) cts = extract('card_types', @project) mappings.collect do |mapping| if (match?(mapping)) pd = pds.find { |pd| pd['id'] && pd['id'] == mapping['property_definition_id'] } ct = cts.find { |ct| ct['id'] == mapping['card_type_id'] } OpenStruct.new(:card_type => CardTypeLoader.new(@project, ct).load, :property_definition => PropertyDefinitionLoader.new(@project, pd).load) end end.compact end |