class Apotomo::WidgetShortcuts::FactoryProxy

Public Class Methods

new(prefix, *args, &block) click to toggle source
# File lib/apotomo/widget_shortcuts.rb, line 36
def initialize(prefix, *args, &block)
  options = args.extract_options!
  id      = args.shift || prefix
  
  @prefix, @id, @options, @block = prefix, id, options, block
end

Public Instance Methods

build(parent) click to toggle source
# File lib/apotomo/widget_shortcuts.rb, line 43
def build(parent)
  widget = constant_for(@prefix).new(parent, @id, @options)
  @block.call(widget) if @block
  widget
end

Private Instance Methods

constant_for(class_name) click to toggle source
# File lib/apotomo/widget_shortcuts.rb, line 50
def constant_for(class_name)  # TODO: use Cell.class_from_cell_name.
  "#{class_name}_widget".classify.constantize
end