Module: ActsAsPolymorphicController::InstanceMethods

Defined in:
lib/acts_as_polymorphic_controller/controller.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#aapc_parent_classObject



34
35
36
# File 'lib/acts_as_polymorphic_controller/controller.rb', line 34

def aapc_parent_class
  aapc_parent_type && aapc_parent_type.to_s.classify.constantize
end

#aapc_parent_controllerObject



42
43
44
# File 'lib/acts_as_polymorphic_controller/controller.rb', line 42

def aapc_parent_controller
  aapc_parent_type.to_s.pluralize
end

#aapc_parent_id(parent) ⇒ Object



26
27
28
# File 'lib/acts_as_polymorphic_controller/controller.rb', line 26

def aapc_parent_id(parent)  
  params["#{parent}_id"]
end

#aapc_parent_objectObject



38
39
40
# File 'lib/acts_as_polymorphic_controller/controller.rb', line 38

def aapc_parent_object
  aapc_parent_class && aapc_parent_class.find_by_id(aapc_parent_id(aapc_parent_type))
end

#aapc_parent_typeObject



30
31
32
# File 'lib/acts_as_polymorphic_controller/controller.rb', line 30

def aapc_parent_type
  @aapc_parent_objects.detect { |parent| aapc_parent_id(parent) }
end