Skip to content

Commit

Permalink
Simplify Dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Aug 24, 2010
1 parent 8a324e4 commit 5e6c390
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
35 changes: 3 additions & 32 deletions lib/pickle/dsl.rb
@@ -1,44 +1,15 @@
module Pickle
# included into cucumber scenarios via World(Pickle::Scenario)
#
# for more fine-grained access to the pickle session, see Pickle::Session::Api
# the pickle object is where all of the action is at, see Pickle::Session::Api
module Dsl
include MakeMatcher

# retrieve the model with the given pickle_ref from the pickle session, and re-find it from the database
# @raise Pickle::UnknownModelError
# @return Object the stored model
def model(pickle_ref)
pickle.retrieve_and_reload(pickle_ref)
end

# does the model with given pickle_ref exist in the pickle session?
# @return falsy if pickle_ref not know, truthy otherwise
def model?(pickle_ref)
pickle.known?(pickle_ref)
end

# make a model using the pickle_ref, and optional fields, and store it in the pickle session under its pickle_ref
# @return Object the newly made model
def make(pickle_ref, fields = nil)
pickle.make_and_store(pickle_ref, fields)
end

# find a model using the given pickle_ref and optional fields, and store it in the pickle session under its pickle_ref
# @return Object the found object
def find(pickle_ref, fields = nil)
pickle.find_and_store(pickle_ref, fields)
end

# find all models using the given plural factory name, and optional fields, and store them in the pickle session using the factory name
# @return Array array of found objects
def find_all(plural, fields = nil)
pickle.find_all_and_store(plural, fields)
end

# the pickle session, @see Pickle::Session::Api
def pickle
@pickle ||= Pickle::Session.new
end

delegate :model, :to => :pickle
end
end
3 changes: 0 additions & 3 deletions lib/pickle/ref.rb
@@ -1,6 +1,3 @@
require 'pickle/parser/matchers'
require 'pickle/parser/canonical'

module Pickle
class InvalidPickleRefError < RuntimeError
end
Expand Down
1 change: 0 additions & 1 deletion lib/pickle/session.rb
Expand Up @@ -12,7 +12,6 @@ def jar
@jar ||= Pickle::Jar.new
end


class Object
include Pickle::Session
end
Expand Down

0 comments on commit 5e6c390

Please sign in to comment.