Module: Pragma::Operation::Defaults::ClassMethods

Defined in:
lib/pragma/operation/defaults.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#contract_klassClass

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.

Returns:

  • (Class)


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_klassClass

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.

Returns:

  • (Class)


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_klassObject

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_klassClass

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.

Returns:

  • (Class)


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