Class: AdminWidgets::ViewProxy

Inherits:
ActiveSupport::BasicObject
Defined in:
lib/admin_widgets/view_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, widget) ⇒ ViewProxy

Returns a new instance of ViewProxy.



6
7
8
9
# File 'lib/admin_widgets/view_proxy.rb', line 6

def initialize(view, widget)
  @widget = widget
  @view = buffered_view(view)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



11
12
13
14
15
16
17
18
# File 'lib/admin_widgets/view_proxy.rb', line 11

def method_missing(method_name, *args, &block)
  target = case
    when widget.dsl_methods.include?(method_name.to_sym) then @widget
    else @view
  end

  target.send(method_name, *args, &block)
end

Instance Attribute Details

#widgetObject

Returns the value of attribute widget.



4
5
6
# File 'lib/admin_widgets/view_proxy.rb', line 4

def widget
  @widget
end