class ArtDeco::Decorator

Attributes

component[R]

Public Class Methods

factory(component) click to toggle source
# File lib/art_deco/decorator.rb, line 38
def self.factory(component)
  begin
    "#{component.class.name}Decorator".constantize.new(component)
  rescue
    ArtDeco::Decorator.new(component)
  end
end
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/art_deco/decorator.rb, line 46
def self.method_missing(method_name, *args, &block)
  if self.constant_name.constantize.respond_to?(method_name)
    self.constant_name.constantize.send(method_name, *args, &block)
  else
    super
  end
end
new(component) click to toggle source
# File lib/art_deco/decorator.rb, line 5
def initialize(component)
  self.instance_variable_set "@#{component.class.name.downcase}".to_sym, component
  @component = component
end
respond_to_missing?(method_name, include_private = false) click to toggle source
# File lib/art_deco/decorator.rb, line 54
def self.respond_to_missing?(method_name, include_private = false)
  self.constant_name.constantize.respond_to?(method_name)
end
wrap(collection) click to toggle source
# File lib/art_deco/decorator.rb, line 20
def self.wrap(collection)
  collection.map{ |component| ArtDeco::Decorator.factory(component) }
end

Private Class Methods

constant_name() click to toggle source
# File lib/art_deco/decorator.rb, line 60
def self.constant_name
  name = self.name.gsub(/Decorator\z/, '')
  name = 'Decorator' if name.length.zero?
  return name
end

Public Instance Methods

h()
Alias for: helpers
helpers() click to toggle source
# File lib/art_deco/decorator.rb, line 10
def helpers
  ViewContext.current
end
Also aliased as: h
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/art_deco/decorator.rb, line 26
def method_missing(method_name, *args, &block)
  if @component.respond_to?(method_name)
    @component.send(method_name, *args)
  else
    super
  end
end
respond_to_missing?(method_name, include_private = false) click to toggle source
# File lib/art_deco/decorator.rb, line 34
def respond_to_missing?(method_name, include_private = false)
  @component.respond_to?(method_name)
end
t(*args)
Alias for: translate
translate(*args) click to toggle source
# File lib/art_deco/decorator.rb, line 16
def translate(*args)
  I18n.translate(*args)
end
Also aliased as: t