Module: Pragma::Operation::Defaults::ClassMethods
- Defined in:
- lib/pragma/operation/defaults.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#contract_klass ⇒ Class
Returns the contract class for the current resource (if the inferred class exists).
-
#decorator_klass ⇒ Class
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 ⇒ Class
Returns the policy class for the current resource (if the inferred class exists).
Instance Method Details
#contract_klass ⇒ Class
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.
43 44 45 46 47 |
# File 'lib/pragma/operation/defaults.rb', line 43 def contract_klass super || ( Object.const_get(computed_contract_klass) if class_exists?(computed_contract_klass) ) end |
#decorator_klass ⇒ Class
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.
19 20 21 22 23 |
# File 'lib/pragma/operation/defaults.rb', line 19 def decorator_klass super || ( Object.const_get(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.
52 53 54 |
# File 'lib/pragma/operation/defaults.rb', line 52 def model_klass Object.const_get("::#{name.split('::')[0..-3].last}") end |
#policy_klass ⇒ Class
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.
31 32 33 34 35 |
# File 'lib/pragma/operation/defaults.rb', line 31 def policy_klass super || ( Object.const_get(computed_policy_klass) if class_exists?(computed_policy_klass) ) end |