Method: Medea::JasonObject.method_missing

Defined in:
lib/medea/jasonobject.rb

.method_missing(name, *args, &block) ⇒ Object

here we will capture: members_of(object) (where object is an instance of a class that this class can be a member of) find_by_<property>(value) Will return a JasonDeferredQuery for this class with the appropriate data filter set



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/medea/jasonobject.rb', line 36

def JasonObject.method_missing(name, *args, &block)

  q = all
  if name.to_s =~ /^members_of$/
    #use the type and key of the first arg (being a JasonObject)
    return q.members_of args[0]
  elsif name.to_s =~ /^find_by_(.*)$/
    #use the property name from the name variable, and the value from the first arg
    q.add_data_filter $1, args[0]

    return q
  else
    #no method!
    super
  end
end