Sha256: 9eca8542555e079d4baa24023614fc4e403445da1657e7283cb175de85dbb17d

Contents?: true

Size: 972 Bytes

Versions: 24

Compression:

Stored size: 972 Bytes

Contents

module RailsAdmin
  module Adapters
    module ActiveRecord
      class AbstractObject
        # undef almost all of this class's methods so it will pass almost
        # everything through to its delegate using method_missing (below).
        instance_methods.each { |m| undef_method m unless m.to_s =~ /(^__|^send$|^object_id$)/ }
        #                                                  ^^^^^
        # the unnecessary "to_s" above is a workaround for meta_where, see
        # https://github.com/sferik/rails_admin/issues/374

        attr_accessor :object

        def initialize(object)
          self.object = object
        end

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

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

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

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
rails_admin-1.4.3 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-2.0.1 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-2.0.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-2.0.0.rc lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-2.0.0.beta lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.4.2 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.4.1 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.4.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.3.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.2.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.1.1 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.1.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.0.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-1.0.0.rc lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-0.8.1 lib/rails_admin/adapters/active_record/abstract_object.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails_admin-0.7.0/lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-0.7.0 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-0.6.8 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-0.6.7 lib/rails_admin/adapters/active_record/abstract_object.rb
rails_admin-0.6.6 lib/rails_admin/adapters/active_record/abstract_object.rb