class BeerRecipe::Wrapper
Public Class Methods
new(record, recipe=nil)
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 2 def initialize(record, recipe=nil) @record = record @recipe = recipe end
set(recipe, set)
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 23 def self.set(recipe, set) if set.respond_to? :map set.map { |record| self.wrap(record, recipe) } else [] end end
wrap(record, recipe)
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 31 def self.wrap(record, recipe) wrapper = "#{record.record_type.capitalize}Wrapper".to_sym begin return BeerRecipe.const_get(wrapper).new(record, recipe) rescue NameError return self.new(record, recipe) end end
Public Instance Methods
blank?(obj)
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 19 def blank?(obj) obj.nil? || (obj.respond_to?(:empty?) && obj.empty?) end
format_method()
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 15 def format_method "format_#{record_type}".to_sym end
method_missing(method, *args, &block)
click to toggle source
# File lib/beer_recipe/wrapper.rb, line 7 def method_missing(method, *args, &block) @record.send(method, *args, &block) end
respond_to_missing?(name, flag = true)
click to toggle source
Calls superclass method
# File lib/beer_recipe/wrapper.rb, line 11 def respond_to_missing?(name, flag = true) @record.respond_to?(name) || super end