Module: CaTissue::Resource

Overview

The module included by all CaTissue domain classes.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Annotatable

#annotation_proxy, #create_proxy, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CaTissue::Annotatable

Class Method Details

.included(klass) ⇒ Object

Adds the given domain class to the CaTissue domain module.

Parameters:

  • klass (Class)

    the included class



16
17
18
19
20
21
22
23
24
# File 'lib/catissue/resource.rb', line 16

def self.included(klass)
  super
  CaTissue.add_class(klass)
  # defer loading AnnotatableClass to avoid pulling in Database, which in turn
  # attempts to import java classes before the path is established. obscure
  # detail, but don't know how to avoid it.
  require 'catissue/annotation/annotatable_class'
  klass.extend(AnnotatableClass)
end

Instance Method Details

#databaseObject

Returns the CaTissue::Database which stores this object.



38
39
40
# File 'lib/catissue/resource.rb', line 38

def database
  CaTissue::Database.instance
end

#tolerant_match?(other, attributes) ⇒ Boolean

Returns whether each of the given attribute values either equals the respective other attribute value or one of the values is nil or ‘Not Specified’.

Parameters:

  • other (Resource)

    the domain object to compare

  • attributes (<Symbol>)

    the attributes to compare

Returns:

  • (Boolean)

    whether this domain object is a tolerant match with the other domain object on the given attributes



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

def tolerant_match?(other, attributes)
  attributes.all? { |attr| Resource.tolerant_value_match?(send(attr), other.send(attr)) }
end