Class: RailsAdmin::Adapters::ActiveRecord::AbstractObject

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

Direct Known Subclasses

Mongoid::AbstractObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ AbstractObject

Returns a new instance of AbstractObject.



14
15
16
# File 'lib/rails_admin/adapters/active_record/abstract_object.rb', line 14

def initialize(object)
  self.object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



26
27
28
# File 'lib/rails_admin/adapters/active_record/abstract_object.rb', line 26

def method_missing(method_name, *args, &block)
  object.send(method_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



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

def object
  @object
end

Instance Method Details

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



22
23
24
# File 'lib/rails_admin/adapters/active_record/abstract_object.rb', line 22

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

#set_attributes(attributes) ⇒ Object



18
19
20
# File 'lib/rails_admin/adapters/active_record/abstract_object.rb', line 18

def set_attributes(attributes)
  object.assign_attributes(attributes) if attributes
end