Skip to content

Commit

Permalink
Adding context to find, closes drapergem#28
Browse files Browse the repository at this point in the history
  • Loading branch information
jcasimir committed Oct 3, 2011
1 parent f1d61a6 commit 1e28686
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/draper/base.rb
Expand Up @@ -32,8 +32,8 @@ def initialize(input, context = {})
#
# @param [Symbol or String] id to lookup
# @return [Object] instance of this decorator class
def self.find(input)
self.new(model_class.find(input))
def self.find(input, context = {})
self.new(model_class.find(input), context)
end

# Typically called within a decorator definition, this method
Expand Down
5 changes: 5 additions & 0 deletions spec/base_spec.rb
Expand Up @@ -89,6 +89,11 @@ class BusinessDecorator < Draper::Base
pd.should be_instance_of(ProductDecorator)
pd.model.should be_instance_of(Product)
end

it "should accept and store a context" do
pd = ProductDecorator.find(1, :admin)
pd.context.should == :admin
end
end

context ".decorate" do
Expand Down

0 comments on commit 1e28686

Please sign in to comment.