Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Fixing name collisions, fixed adding pavlov options, removed creating…
Browse files Browse the repository at this point in the history
… pavlov_options in compatablity layer.
  • Loading branch information
jjoos committed Jul 25, 2013
1 parent db76889 commit 02d0588
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
15 changes: 4 additions & 11 deletions lib/pavlov/alpha_compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,22 @@ def self.arguments_to_attributes(operation_class, arguments)

module Helpers
def old_interactor name, *args
args = add_pavlov_options args
args = add_compatablity_pavlov_options args
Pavlov.old_interactor name, *args
end

def old_query name, *args
args = add_pavlov_options args
args = add_compatablity_pavlov_options args
Pavlov.old_query name, *args
end

def old_command name, *args
args = add_pavlov_options args
args = add_compatablity_pavlov_options args
Pavlov.old_command name, *args
end

def pavlov_options
{}
end

private
def add_pavlov_options args
def add_compatablity_pavlov_options args
# TODO: we should do this at a point where we know how many arguments we need
# so we can decide if we need to merge with another options object or
# just add it.
Expand All @@ -67,9 +63,6 @@ def arguments(*args)
args.each do |argument|
attribute argument, Object
end

# Add attribute for pavlov_options
attribute :pavlov_options, Hash, default: {}

This comment has been minimized.

Copy link
@marten

marten Jul 25, 2013

Contributor

If you remove this, they won't be magically available, and you'd have to add them to each operation that needs it. Is that what you wanted?

This comment has been minimized.

Copy link
@jjoos

jjoos Jul 25, 2013

Author Member

Yes otherwise if we migrate operations to the new attribute methods it would magically disappear.

end
end
end
Expand Down
28 changes: 13 additions & 15 deletions lib/pavlov/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
module Pavlov
module Helpers
def interactor name, *args
args = add_pavlov_options args
Pavlov.interactor name, *args
def interactor name, hash
hash = add_pavlov_options hash
Pavlov.interactor name, hash
end

def query name, *args
args = add_pavlov_options args
Pavlov.query name, *args
def query name, hash
hash = add_pavlov_options hash
Pavlov.query name, hash
end

def command name, *args
args = add_pavlov_options args
Pavlov.command name, *args
def command name, hash
hash = add_pavlov_options hash
Pavlov.command name, hash
end

def pavlov_options
{}
end

private
def add_pavlov_options args
# TODO: we should do this at a point where we know how many arguments we need
# so we can decide if we need to merge with another options object or
# just add it.
def add_pavlov_options hash
if pavlov_options != {}
args << pavlov_options
hash ||= {}
hash[:pavlov_options] = pavlov_options.merge(hash[:pavlov_options])
end
args
hash
end
end
end

0 comments on commit 02d0588

Please sign in to comment.