Module: CaTissue::Annotatable

Included in:
Resource
Defined in:
lib/catissue/annotation/annotatable.rb

Overview

Resource annotation hook mix-in.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mth, *args) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/catissue/annotation/annotatable.rb', line 6

def method_missing(mth, *args)
  name = mth.to_s
  # remove trailing assignment '=' character if present
  attr = name =~ /=$/ ? name.chop.to_sym : mth
  # If an annotation can be generated on demand, then resend the method.
  # Otherwise, delegate to super for the standard error.
  self.class.annotation_attribute?(attr) ? send(mth, *args) : super
end

Instance Method Details

#annotation_proxy(attribute) ⇒ Annotation

Returns the hook -> proxy attribute.

Parameters:

  • attribute (Symbol)

    the hook -> annotation attribute

Returns:



31
32
33
34
35
# File 'lib/catissue/annotation/annotatable.rb', line 31

def annotation_proxy(attribute)
  pxy_attr = self.class.annotation_proxy_attribute(attribute)
  # the hook -> proxy attribute value
  send(pxy_attr)
end

#create_proxy(klass) ⇒ Resource

Creates a CaTissue::Annotation::Proxy whose hook reference is set to this annotatable object.

Parameters:

  • the (Class)

    proxy class

Returns:



19
20
21
22
23
24
25
26
# File 'lib/catissue/annotation/annotatable.rb', line 19

def create_proxy(klass)
  # make the proxy instance
  pxy = klass.new
  # set the proxy hook reference to this hook instance
  pxy.hook = self
  logger.debug { "Created #{qp} #{klass.domain_module.qp} annotation proxy #{pxy}." }
  pxy
end