Class: RTM::AR::Locators

Inherits:
TMSetDelegator show all
Defined in:
lib/rtm/activerecord/set_wrapper.rb

Instance Method Summary collapse

Methods inherited from TMSetDelegator

#&, #==, #add, #add_all, #content_class, #delete, #each, #empty?, #find, #first, #include?, #initialize, #last, #method_missing, #old_method_missing, #old_respond_to?, #respond_to?, #size, #to_s, wrap

Methods inherited from TMDelegator

#__getobj__, #__setobj__, aka_property, class_delegate, delegate, #eql?, equality, #hash, #initialize, parent, property, property_set, wrapper_cache

Constructor Details

This class inherits a constructor from RTM::AR::TMSetDelegator

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RTM::AR::TMSetDelegator

Instance Method Details

#[](obj) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/rtm/activerecord/set_wrapper.rb', line 61

def [](obj)
  # support for getting locators by reference
  if obj.is_a? String
    return wrap(__getobj__.find { |tm| tm.reference == obj })
  end
  # normal index retrieval
  super
end

#wrap(obj) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rtm/activerecord/set_wrapper.rb', line 69

def wrap(obj)
  return nil unless obj
  return obj if obj.respond_to? :__getobj__
  case obj.class.name
  when "RTM::AR::TMDM::ItemIdentifier"
    ItemIdentifier.wrap(obj)
  when "RTM::AR::TMDM::SubjectIdentifier"
    SubjectIdentifier.wrap(obj)
  when "RTM::AR::TMDM::SubjectLocator"
    SubjectLocator.wrap(obj)        
  else
    Locator.wrap(obj)
  end
end