Skip to content

Commit

Permalink
configurtion options
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw committed Oct 30, 2011
1 parent 629eeb3 commit 641f0bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/cantango_editor/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ module Configuration
attr_accessor *conf_methods_available

conf_methods.each do |cm|
define_method :"#{cm}_available" do
instance_variable_get(:"@#{cm}_available") || send(:"#{cm}_default")
end
class_eval %{
def #{cm}_available
@#{cm}_available ||= #{cm}_default
end
}
end

def models_default
Expand Down
3 changes: 3 additions & 0 deletions spec/cantango_editor/configuration/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def configuration_methods
it "should allow alternate values" do
conf.send(:"#{conf_method}_available=", [:whatever])
conf.send(:"#{conf_method}_available").should == [:whatever]

conf.send(:"#{conf_method}_available") << :more
conf.send(:"#{conf_method}_available").should == [:whatever, :more]
end
end
end
Expand Down

0 comments on commit 641f0bf

Please sign in to comment.