Class: Widget::Base
- Inherits:
-
Object
- Object
- Widget::Base
- Defined in:
- app/widgets/widget/base.rb
Instance Attribute Summary collapse
-
#view_context ⇒ Object
Returns the value of attribute view_context.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(view_context, options = {}, &block) ⇒ Base
constructor
A new instance of Base.
- #render(action = nil) ⇒ Object
Constructor Details
#initialize(view_context, options = {}, &block) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/widgets/widget/base.rb', line 17 def initialize(view_context, = {}, &block) .reverse_merge!(frame: false, remote: false) @view_context = view_context @options = @block = block @view_options = {} @remote = .delete(:remote) @frame = .delete(:frame) add_helpers_to_view_context end |
Instance Attribute Details
#view_context ⇒ Object
Returns the value of attribute view_context.
3 4 5 |
# File 'app/widgets/widget/base.rb', line 3 def view_context @view_context end |
Class Method Details
.default_action ⇒ Object
5 6 7 |
# File 'app/widgets/widget/base.rb', line 5 def self.default_action :show end |
.helper(helper) ⇒ Object
9 10 11 |
# File 'app/widgets/widget/base.rb', line 9 def self.helper(helper) helpers << helper end |
.helpers ⇒ Object
13 14 15 |
# File 'app/widgets/widget/base.rb', line 13 def self.helpers @helpers ||= [] end |
Instance Method Details
#render(action = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/widgets/widget/base.rb', line 31 def render(action = nil) action ||= self.class.default_action send(action) output = "" output << @view_context.content_tag(:div, class: , id: dom_id, :'data-widget' => , :'data-widgetaction' => action, :'data-container' => container_dom_id) do @view_context.render(partial: '/widget/base/widget_controls', formats: [:html], locals: { dom_id: dom_id}) + @view_context.render(partial: partial_path(action), formats: [:html], locals: view_locals) unless @remote end output << remote_load_code(action) if @remote output.html_safe end |