Class: Arpa::Services::Resources::ResourceManagerCreator

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/arpa/services/resources/resource_manager_creator.rb

Instance Method Summary collapse

Methods included from Base

included, #manager_action

Instance Method Details

#create(params, callback) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/arpa/services/resources/resource_manager_creator.rb', line 7

def create(params, callback)
  manager_action callback do
    resourceables         = params[:resourceables]
    except_action_methods = params[:except_action_methods] || []

    resource_remover.remove_nonexistent_resources(resourceables)

    resourceables.collect do |resourceable|
      resource = resource_creator.create(resourceable)
      action_params = action_params(resource, resourceable, except_action_methods)

      action_remover.remove_nonexistent_actions(action_params)
      action_creator.create_many(action_params)

      resource
    end
  end
end