Class: ActionWidget::Base
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ActionWidget::Base
- Includes:
- SmartProperties
- Defined in:
- lib/action_widget/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(view, attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #render ⇒ Object
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, = attributes.partition { |name, value| properties.key?(name) } @options = Hash[] super(view, Hash[attributes]) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/action_widget/base.rb', line 6 def @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
#render ⇒ Object
21 22 23 |
# File 'lib/action_widget/base.rb', line 21 def render raise NotImplementedError, "#{self.class} must implement #render" end |