Module: MongoidAdapter::InstanceMethods

Defined in:
lib/models/mongoid_adapter.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



62
63
64
65
# File 'lib/models/mongoid_adapter.rb', line 62

def method_missing(meth, *args, &block)
  #cool I just found out * on an array turns the array into a list of args for a function
  @instance.send(meth, *args, &block)
end

Instance Method Details

#errorsObject



58
59
60
# File 'lib/models/mongoid_adapter.rb', line 58

def errors
  @instance.errors.full_messages.join(', ')
end

#savedObject



54
55
56
# File 'lib/models/mongoid_adapter.rb', line 54

def saved
  @instance.valid?
end

#update(attributes) ⇒ Object



49
50
51
52
# File 'lib/models/mongoid_adapter.rb', line 49

def update(attributes)
  @instance.update_attributes(attributes)
  @instance.save
end

#validObject



45
46
47
# File 'lib/models/mongoid_adapter.rb', line 45

def valid
  @instance.valid?
end