Skip to content

Commit

Permalink
Allow use of parameter-declaration options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdub committed Nov 10, 2010
1 parent dea9a44 commit 09167e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/clamp/parameter/declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def parameters
@parameters ||= []
end

def parameter(name, description, &block)
parameter = Parameter.new(name, description)
def parameter(name, description, options = {}, &block)
parameter = Parameter.new(name, description, options)
parameters << parameter
define_accessors_for(parameter, &block)
end
Expand Down
13 changes: 13 additions & 0 deletions spec/clamp/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ def color=(c)
@command.flavour.should == "chocolate"
end

describe "with explicit :attribute_name" do

before do
@command.class.parameter "FOO", "a foo", :attribute_name => :bar
end

it "uses the specified attribute_name name to name accessors" do
@command.bar = "chocolate"
@command.bar.should == "chocolate"
end

end

describe "with a block" do

before do
Expand Down

0 comments on commit 09167e1

Please sign in to comment.