Class: RailsAdmin::AbstractObject

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_admin/abstract_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ AbstractObject

Returns a new instance of AbstractObject.



12
13
14
# File 'lib/rails_admin/abstract_object.rb', line 12

def initialize(object)
  self.object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
# File 'lib/rails_admin/abstract_object.rb', line 20

def method_missing(name, *args, &block)
  self.object.send(name, *args, &block)
end

Instance Attribute Details

#objectObject

^^^^^ the unnecessary “to_s” above is a workaround for meta_where, see github.com/sferik/rails_admin/issues/374



10
11
12
# File 'lib/rails_admin/abstract_object.rb', line 10

def object
  @object
end

Instance Method Details

#save(options = { :validate => true }) ⇒ Object



24
25
26
# File 'lib/rails_admin/abstract_object.rb', line 24

def save(options = { :validate => true })
  object.save(options)
end

#set_attributes(attributes, role = nil) ⇒ Object



16
17
18
# File 'lib/rails_admin/abstract_object.rb', line 16

def set_attributes(attributes, role = nil)
  object.assign_attributes(attributes, :as => role)
end