Class: Dry::Ability::InheritedResource

Inherits:
Controller::Resource show all
Defined in:
lib/dry/ability/inherited_resource.rb

Overview

For use with Inherited Resources

Instance Method Summary collapse

Methods inherited from Controller::Resource

#assign_attributes, #authorization_action, #authorize_resource, #call, #collection_instance, #collection_instance=, #current_ability, #id_param, #initial_attributes, #load_and_authorize_resource, #load_collection, #load_instance?, #load_resource, #parameters_require_sanitizing?, #params_method, #parent?, #parent_name, #parent_resource, #resource_class, #resource_class_with_parent, #resource_instance, #resource_instance=, #resource_params, #resource_params_by_namespaced_name, #skip?

Instance Method Details

#load_resource_instanceObject

:nodoc:



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dry/ability/inherited_resource.rb', line 9

def load_resource_instance
  if parent?
    @controller.send :association_chain
    @controller.instance_variable_get(:"@#{instance_name}")
  elsif new_actions.include?(@action_name)
    resource = @controller.send :build_resource
    assign_attributes(resource)
  else
    @controller.send :resource
  end
end

#resource_baseObject



21
22
23
# File 'lib/dry/ability/inherited_resource.rb', line 21

def resource_base
  @controller.send :end_of_association_chain
end