Class: RKit::Decorator::Base

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/r_kit/decorator/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, view_context: nil) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/r_kit/decorator/base.rb', line 6

def initialize obj, view_context: nil
  @_view_context = view_context
  super obj
end

Instance Method Details

#===(object) ⇒ Object



21
22
23
# File 'lib/r_kit/decorator/base.rb', line 21

def === object
  self == object || __getobj__ == object
end

#_view_contextObject



12
13
14
# File 'lib/r_kit/decorator/base.rb', line 12

def _view_context
  backtrace{ |obj| obj.is_a? ActionView::Base } || backtrace{ |obj| obj.respond_to? :view_context }.view_context
end

#viewObject



16
17
18
# File 'lib/r_kit/decorator/base.rb', line 16

def view
  @_view_context ||= _view_context
end