controlist 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fe714a3aad4e99f1f5939eaeb793a6b61c485cf
4
- data.tar.gz: 99b51da4fc36bd7c17f92d3de8c4c0afbace75dc
3
+ metadata.gz: 869f2a6dde29f0147539df3d68e2ac711cc13455
4
+ data.tar.gz: bdc0da9ca4091b91573da88c9fbf42082e20869f
5
5
  SHA512:
6
- metadata.gz: 5791061e742d2fd3f2dd9ae8fdd3cbb7ef211cdf9ddd5689e36b51ff650dae29b6202371125994a8d32cb8be1c74c839fdb68855bafe0925279778960bce6afc
7
- data.tar.gz: b9fbeedd4de2e2c92f01fd5fdc1b9e7171dc8977a7bcbf9a594a596001a78b4b6a28fee60b095985e3646340f8061f4be21b732d9a77e5fa4a424c6f46ab0e39
6
+ metadata.gz: 6d0ec5252374ad3c4f564520f762640fd3e33e397e75f3f6fb72fe501c3143ea66e1db258ae4e03847c5c04a9171eb3e7bc379340262737acbba4d3ab0be8d02
7
+ data.tar.gz: 9669e13a1bc8fc97a7f1c85862cae8a1f15471c3d2451293222b83c7bc8997ddbf2a54e1b13b761515e053df836ad2d6d1f625334b1dcc96abf0fa01c7c86191
@@ -4,7 +4,7 @@ module Controlist
4
4
  class AdvancedConstrain < Constrain
5
5
 
6
6
  def initialize(hash)
7
- self.property = hash[:property]
7
+ self.property = hash[:property].to_s
8
8
  self.value = hash[:value]
9
9
  self.relation = hash[:relation]
10
10
  self.table_name = hash[:table_name]
@@ -3,11 +3,9 @@ module Controlist
3
3
 
4
4
  class SimpleConstrain < Constrain
5
5
 
6
- def initialize(property, value, hash={})
6
+ def initialize(property, value)
7
7
  self.property = property.to_s
8
8
  self.value = value
9
- self.relation = hash[:relation]
10
- self.table_name = hash[:table_name]
11
9
  end
12
10
 
13
11
  end
@@ -1,3 +1,3 @@
1
1
  module Controlist
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/test/feature_test.rb CHANGED
@@ -23,7 +23,7 @@ class FeatureTest < ActiveSupport::TestCase
23
23
  Controlist.permission_provider.set_permission_package(OrderedPackage.new(
24
24
  Controlist::Permission.new(User, READ, true, [
25
25
  SimpleConstrain.new("name", "Tom"),
26
- SimpleConstrain.new("name", ["Grade 1", "Grade 2"], relation: "clazz"),
26
+ AdvancedConstrain.new(property: "name", value: ["Grade 1", "Grade 2"], relation: "clazz"),
27
27
  AdvancedConstrain.new(property: "age", value: 5, operator: ">="),
28
28
  SimpleConstrain.new("age", "null"),
29
29
  SimpleConstrain.new("age", [1,2,3]),
@@ -96,15 +96,15 @@ class FeatureTest < ActiveSupport::TestCase
96
96
  Controlist::Permission.new(Clazz, READ),
97
97
  Controlist::Permission.new(User, READ),
98
98
  Controlist::Permission.new(User, UPDATE, false, AdvancedConstrain.new(property: "name", value: "To", operator: "include?")),
99
- Controlist.is_activerecord3? ? nil : Controlist::Permission.new(User, UPDATE, false, AdvancedConstrain.new(proc_persistence: lambda{|object, operation| object.name == 'Block'})),
100
- Controlist::Permission.new(User, [UPDATE, DELETE], false, SimpleConstrain.new("name", "Grade 1", relation: 'clazz')),
99
+ Controlist.is_activerecord3? ? nil : Controlist::Permission.new(User, UPDATE, false, AdvancedConstrain.new(proc_persistence: lambda{|object, operation| object.name == "Block"})),
100
+ Controlist::Permission.new(User, [UPDATE, DELETE], false, AdvancedConstrain.new(property: "name", value: "Grade 1", relation: "clazz")),
101
101
  Controlist::Permission.new(User, UPDATE)
102
102
  ))
103
103
 
104
104
  user = User.find 3
105
105
  assert_not_equal "Tom", user.name
106
106
  assert_not_equal "Grade 1", user.clazz.name
107
- user.name = 'Test'
107
+ user.name = "Test"
108
108
  assert_equal true, user.save
109
109
 
110
110
  unless Controlist.is_activerecord3?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler