Module: Cardiac::ExtensionMethods

Included in:
Resource
Defined in:
lib/cardiac/resource/extension_methods.rb

Instance Method Summary collapse

Instance Method Details

#__extension_defined__?(name) ⇒ Boolean

Checks if an extension is defined.

Returns:

  • (Boolean)


33
34
35
# File 'lib/cardiac/resource/extension_methods.rb', line 33

def __extension_defined__?(name)
  __extension_module__.method_defined? name
end

#__extension_module__Object

Lazily builds the extension module, then redefines this method as an attr_reader.



26
27
28
29
30
# File 'lib/cardiac/resource/extension_methods.rb', line 26

def __extension_module__
  build_extension_module if extensions_values.any? || operations_values.any? || subresources_values.any?
ensure
  singleton_class.class_eval "attr_reader :__extension_module__"
end

#extending(*modules, &extension_block) ⇒ Object

Declares an extension module to be included into this resource’s extension module.



20
21
22
23
# File 'lib/cardiac/resource/extension_methods.rb', line 20

def extending(*modules, &extension_block)
  self.extensions_values += check_extensions(modules, extension_block)
  self
end

#operation(name, implementation) ⇒ Object

Defines an operation on this resource.



8
9
10
11
# File 'lib/cardiac/resource/extension_methods.rb', line 8

def operation(name, implementation)
  self.operations_values << check_operation(name, implementation)
  self
end

#subresource(name, implementation, &extension_block) ⇒ Object

Defines a subresource on this resource.



14
15
16
17
# File 'lib/cardiac/resource/extension_methods.rb', line 14

def subresource(name, implementation, &extension_block)
  self.subresources_values << check_subresource(name, implementation, extension_block)
  self
end