active_restrictors 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == v0.2.3
2
+ * Adds :scope key to :views hash in restrictor to limit valid assignments
3
+
1
4
  == v0.2.2
2
5
  * Added support for formtastic to view helpers
3
6
  * Cleaned up dynamic method generation
@@ -47,7 +47,14 @@ module ActiveRestrictors
47
47
  end
48
48
  end
49
49
  @_restrictor_inflector_helper ||= Class.send(:include, ActiveSupport::Inflector).new
50
- values = restrictor[:class].find(:all, :order => restrictor[:views][:value]) unless values
50
+ unless(values)
51
+ values = restrictor[:class].scoped
52
+ if(restrictor[:views][:scope])
53
+ scoping = restrictor[:views][:scope].respond_to?(:call) ? restrictor[:views][:scope].call : restrictor[:views][:scope]
54
+ values = values.merge(scoping) if scoping
55
+ values = values.order("#{restrictor[:class].table_name}.#{restrictor[:views][:value]}").all
56
+ end
57
+ end
51
58
  if(defined?(Formtastic) && form.is_a?(Formtastic::FormBuilder))
52
59
  form.input(
53
60
  restrictor[:name],
@@ -13,5 +13,5 @@ module ActiveRestrictors
13
13
  end
14
14
  end
15
15
 
16
- VERSION = Version.new('0.2.2')
16
+ VERSION = Version.new('0.2.3')
17
17
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_restrictors
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Roberts
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-10 00:00:00 -08:00
18
+ date: 2012-02-29 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,7 @@ files:
47
47
  - gemfiles/activerecord3_1.gemfile.lock
48
48
  - gemfiles/activerecord3_0.gemfile
49
49
  - gemfiles/activerecord3_1.gemfile
50
+ - active_restrictors-0.2.2.gem
50
51
  - Gemfile.lock
51
52
  - spec/restrictor_spec.rb
52
53
  - spec/setup.rb