Module: Jat::Plugins::Presenter::ClassMethods

Defined in:
lib/jat/plugins/presenter/presenter.rb

Instance Method Summary collapse

Instance Method Details

#attribute(name, **opts, &block) ⇒ Object



61
62
63
64
65
66
# File 'lib/jat/plugins/presenter/presenter.rb', line 61

def attribute(name, **opts, &block)
  # Define attr_accessor in presenter automatically
  super.tap do |attribute|
    self::Presenter.def_delegator(:__getobj__, attribute.key) unless attribute.params[:block]
  end
end

#inherited(subclass) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/jat/plugins/presenter/presenter.rb', line 53

def inherited(subclass)
  presenter_class = Class.new(self::Presenter)
  presenter_class.jat_class = subclass
  subclass.const_set(:Presenter, presenter_class)

  super
end