Class: RailsAdmin::Config::LazyModel
- Inherits:
-
Object
- Object
- RailsAdmin::Config::LazyModel
- Defined in:
- lib/rails_admin/config/lazy_model.rb
Instance Method Summary collapse
-
#initialize(entity, &block) ⇒ LazyModel
constructor
A new instance of LazyModel.
- #method_missing(method, *args, &block) ⇒ Object
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 |