Class: RailsAdmin::Config::LazyModel

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

Instance Method Summary collapse

Constructor Details

#initialize(entity, &block) ⇒ LazyModel

Returns a new instance of LazyModel.



6
7
8
9
# File 'lib/rails_admin/config/lazy_model.rb', line 6

def initialize(entity, &block)
  @entity = entity
  @deferred_block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



11
12
13
14
15
16
17
18
# File 'lib/rails_admin/config/lazy_model.rb', line 11

def method_missing(method, *args, &block)
  if !@model
    @model = RailsAdmin::Config::Model.new(@entity)
    @model.instance_eval(&@deferred_block) if @deferred_block
  end

  @model.send(method, *args, &block)
end