Skip to content
Browse files

don't define power accessors when using .authorize_values_for

  • Loading branch information...
1 parent 23592ef commit ff7c508bdc18bef6fd8e69aa9f977ad9e0824c9e @henning-koch henning-koch committed Feb 28, 2012
Showing with 6 additions and 8 deletions.
  1. +1 −2 README.md
  2. +0 −1 lib/consul/active_record.rb
  3. +1 −1 lib/consul/version.rb
  4. +4 −4 spec/consul/active_record_spec.rb
View
3 README.md
@@ -212,7 +212,7 @@ Here is a power implementation that can provide a list of assignable values for
Here you can see how to activate the authorization layer and use the new validations:
story = Story.new
- story.power = Power.current # activate the authorization layer
+ Power.current = Power.new(:role => :guest) # activate the authorization layer
story.assignable_states # ['delivered'] # apparently we're not admins
@@ -239,7 +239,6 @@ You can not only authorize scalar attributes like strings or integers that way,
The `authorize_values_for` macro comes with many useful options and details best explained in the [assignable_values README](https://github.com/makandra/assignable_values), so head over there for more. The macro is basically a shortcut for this:
- attr_accessor :power
assignable_values_for :field, :through => lambda { Power.current }
View
1 lib/consul/active_record.rb
@@ -4,7 +4,6 @@ module ActiveRecord
private
def authorize_values_for(property, options = {})
- method_defined?(:power) or attr_accessor :power
assignable_values_for property, options.merge(:through => lambda { ::Power.current })
end
View
2 lib/consul/version.rb
@@ -1,3 +1,3 @@
module Consul
- VERSION = '0.2.0'
+ VERSION = '0.2.1'
end
View
8 spec/consul/active_record_spec.rb
@@ -12,13 +12,13 @@
end
end
- it 'should generate a getter and setter for a @power field' do
+ it 'should not generate a getter and setter for a @power field (change from previous versions)' do
klass = Note.disposable_copy do
authorize_values_for :attribute
end
- song = klass.new
- song.should respond_to(:power)
- song.should respond_to(:power=)
+ note = klass.new
+ note.should_not respond_to(:power)
+ note.should_not respond_to(:power=)
end
it 'should obtain assignable values from Power.current' do

0 comments on commit ff7c508

Please sign in to comment.
Something went wrong with that request. Please try again.