Module: Pragma::Operation::Defaults::ClassMethods
- Defined in:
- lib/pragma/operation/defaults.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#contract_klass ⇒ Object
Returns the contract class for the current resource (if the inferred class exists).
-
#decorator_klass ⇒ Object
Returns the decorator class for the current resource (if the inferred class exists).
-
#model_klass ⇒ Object
Returns the model class for the current resource (if the inferred class exists).
-
#policy_klass ⇒ Object
Returns the policy class for the current resource (if the inferred class exists).
Instance Method Details
#contract_klass ⇒ Object
Returns the contract class for the current resource (if the inferred class exists).
If the operation name is API::V1::Post::Operation::Create, returns API::V1::Post::Contract::Create.
33 34 35 |
# File 'lib/pragma/operation/defaults.rb', line 33 def contract_klass super || (computed_contract_klass if class_exists?(computed_contract_klass)) end |
#decorator_klass ⇒ Object
Returns the decorator class for the current resource (if the inferred class exists).
If the operation name is API::V1::Post::Operation::Show, returns API::V1::Post::Decorator.
17 18 19 |
# File 'lib/pragma/operation/defaults.rb', line 17 def decorator_klass super || (computed_decorator_klass if class_exists?(computed_decorator_klass)) end |
#model_klass ⇒ Object
Returns the model class for the current resource (if the inferred class exists).
If the operation name is API::V1::Post::Operation::Create, returns ::Post.
40 41 42 |
# File 'lib/pragma/operation/defaults.rb', line 40 def model_klass Object.const_get("::#{name.split('::')[0..-3].last}") end |
#policy_klass ⇒ Object
Returns the policy class for the current resource (if the inferred class exists).
If the operation name is API::V1::Post::Operation::Show, returns API::V1::Post::Policy.
25 26 27 |
# File 'lib/pragma/operation/defaults.rb', line 25 def policy_klass super || (computed_policy_klass if class_exists?(computed_policy_klass)) end |