class ActionComponent::Base

Public Class Methods

new(view, opts = {}) click to toggle source
# File lib/action_component/base.rb, line 22
def initialize(view, opts = {})
  check_constraints!(opts)

  opts.each do |key, value|
    instance_variable_set("@#{key}", value)
  end

  @_view = view
end
render(view, opts = {}) click to toggle source
# File lib/action_component/base.rb, line 15
def self.render(view, opts = {})
  component = new(view, opts)
  component.load
  component.render_view
  nil
end

Public Instance Methods

load() click to toggle source
# File lib/action_component/base.rb, line 32
def load
end
render_view() click to toggle source
# File lib/action_component/base.rb, line 39
def render_view
  view
end
view() click to toggle source
# File lib/action_component/base.rb, line 35
def view
  raise ActionComponent::ViewMissingError, "#{self.class.name} must define a view method to be a valid component"
end

Private Instance Methods

component(component, opts = {}) click to toggle source
# File lib/action_component/base.rb, line 65
def component(component, opts = {})
  component.render(@_view, opts)
end
Also aliased as: render_component
form_for(*args, &block) click to toggle source
# File lib/action_component/base.rb, line 71
def form_for(*args, &block)
  text @_view.form_for(*args, &block)
end
form_tag(*args, &block) click to toggle source
# File lib/action_component/base.rb, line 75
def form_tag(*args, &block)
  text @_view.form_tag(*args, &block)
end
insert(content)
Alias for: text
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/action_component/base.rb, line 45
def method_missing(method, *args, &block)
  if @_view.respond_to?(method)
    @_view.send(method, *args, &block)
  else
    super
  end
end
render(*args) click to toggle source
# File lib/action_component/base.rb, line 61
def render(*args)
  @_view.concat(@_view.render(*args))
end
render_component(component, opts = {})
Alias for: component
text(content) click to toggle source
# File lib/action_component/base.rb, line 53
def text(content)
  @_view.concat content
  nil
end
Also aliased as: text_node, insert
text_node(content)
Alias for: text