Class: RailsAdmin::Config::LazyModel
- Inherits:
-
Object
- Object
- RailsAdmin::Config::LazyModel
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
19
20
21
|
# File 'lib/rails_admin/config/lazy_model.rb', line 19
def method_missing(method, *args, &block)
target.send(method, *args, &block)
end
|
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
23
24
25
|
# File 'lib/rails_admin/config/lazy_model.rb', line 23
def respond_to?(method, include_private = false)
super || target.respond_to?(method, include_private)
end
|
#target ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/rails_admin/config/lazy_model.rb', line 11
def target
unless @model
@model = RailsAdmin::Config::Model.new(@entity)
@model.instance_eval(&@deferred_block) if @deferred_block
end
@model
end
|