Class: ActionWidget::Base

Inherits:
SimpleDelegator
  • Object
show all
Includes:
SmartProperties
Defined in:
lib/action_widget/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, attributes = {}) ⇒ Base

Returns a new instance of Base.


13
14
15
16
17
18
19
# File 'lib/action_widget/base.rb', line 13

def initialize(view, attributes = {})
  properties = self.class.properties
  attributes, options = attributes.partition { |name, value| properties.key?(name) }

  @options = Hash[options]
  super(view, Hash[attributes])
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


6
7
8
# File 'lib/action_widget/base.rb', line 6

def options
  @options
end

Class Method Details

.render(view, *args, &block) ⇒ Object


8
9
10
11
# File 'lib/action_widget/base.rb', line 8

def self.render(view, *args, &block)
  attrs = args.last.kind_of?(Hash) ? args.pop : {}
  self.new(view, attrs).render(*args, &block)
end

Instance Method Details

#renderObject

Raises:

  • (NotImplementedError)

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

def render
  raise NotImplementedError, "#{self.class} must implement #render"
end