1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Merge pull request #27 from leshill/default_context

Default context to {}
This commit is contained in:
Jeff Casimir 2011-09-19 22:41:11 -07:00
commit a1d16cbfa7

View file

@ -14,8 +14,9 @@ module Draper
# #
# @param [Object] instance to wrap # @param [Object] instance to wrap
# @param [Object] context (optional) # @param [Object] context (optional)
def initialize(input, context = nil) def initialize(input, context = {})
input.inspect # forces evaluation of a lazy query from AR input.inspect # forces evaluation of a lazy query from AR
input.inspect
self.class.model_class = input.class if model_class.nil? self.class.model_class = input.class if model_class.nil?
@model = input @model = input
self.context = context self.context = context
@ -87,7 +88,7 @@ module Draper
# #
# @param [Object] instance(s) to wrap # @param [Object] instance(s) to wrap
# @param [Object] context (optional) # @param [Object] context (optional)
def self.decorate(input, context = nil) def self.decorate(input, context = {})
input.respond_to?(:each) ? input.map{|i| new(i, context)} : new(input, context) input.respond_to?(:each) ? input.map{|i| new(i, context)} : new(input, context)
end end