Module: Ricordami::CanHaveRelationships::InstanceMethods

Defined in:
lib/ricordami/can_have_relationships.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object (private)



126
127
128
129
130
131
132
133
134
135
# File 'lib/ricordami/can_have_relationships.rb', line 126

def method_missing(meth, *args, &blk)
  match = RE_METHOD.match(meth.to_s)
  meth_root = match.nil?? meth : match[2].to_sym
  if relationship = self.class.relationships[meth_root]
    self.class.send(:"lazy_setup_#{relationship.type}", relationship)
    send(meth, *args, &blk)
  else
    super
  end
end

Instance Method Details

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
145
146
147
# File 'lib/ricordami/can_have_relationships.rb', line 142

def respond_to?(meth)
  match = RE_METHOD.match(meth.to_s)
  meth_root = match.nil?? meth : match[2].to_sym
  return true if self.class.relationships.has_key?(meth_root)
  super
end