happy 0.1.0.pre12 → 0.1.0.pre13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/happy/context.rb +0 -5
- data/lib/happy/ext/permissions.rb +7 -13
- data/lib/happy/ext/resources.rb +2 -2
- data/lib/happy/version.rb +1 -1
- metadata +21 -21
data/lib/happy/context.rb
CHANGED
@@ -23,11 +23,6 @@ module Happy
|
|
23
23
|
old_controller = self.controller
|
24
24
|
self.controller = new_controller
|
25
25
|
|
26
|
-
# execute permissions block SMELL - better integration
|
27
|
-
if controller.class.respond_to?(:permissions_blk)
|
28
|
-
controller.class.permissions_blk.try(:call, permissions, self)
|
29
|
-
end
|
30
|
-
|
31
26
|
# execute block
|
32
27
|
yield
|
33
28
|
ensure
|
@@ -7,27 +7,21 @@ module Happy
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
def permissions(&blk)
|
10
|
-
@permissions ||= Allowance.
|
10
|
+
(@permissions ||= Allowance::Permissions.new).tap do |p|
|
11
|
+
if blk
|
12
|
+
blk.arity == 0 ? p.instance_exec(&blk) : blk.call(p)
|
13
|
+
end
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
permissions.allowed?(*args)
|
15
|
-
end
|
17
|
+
alias_method :can, :permissions
|
16
18
|
end
|
17
19
|
|
18
20
|
module ControllerExtensions
|
19
21
|
extend ActiveSupport::Concern
|
20
22
|
|
21
23
|
included do
|
22
|
-
delegate :can
|
23
|
-
end
|
24
|
-
|
25
|
-
module ClassMethods
|
26
|
-
attr_accessor :permissions_blk
|
27
|
-
|
28
|
-
def permissions(&blk)
|
29
|
-
self.permissions_blk = blk
|
30
|
-
end
|
24
|
+
delegate :permissions, :can, :to => :context
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
data/lib/happy/ext/resources.rb
CHANGED
@@ -23,11 +23,11 @@ module Happy
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def resource_with_permission_scope(*args)
|
26
|
-
|
26
|
+
permissions.scoped_model(*args, options[:class])
|
27
27
|
end
|
28
28
|
|
29
29
|
def require_permission!(*args)
|
30
|
-
raise "not allowed" unless can?(*args, options[:class])
|
30
|
+
raise "not allowed" unless permissions.can?(*args, options[:class])
|
31
31
|
end
|
32
32
|
|
33
33
|
def set_plural_variable(v)
|
data/lib/happy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre13
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70218841196860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70218841196860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70218841195560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70218841195560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: happy-helpers
|
38
|
-
requirement: &
|
38
|
+
requirement: &70218841194520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.0.pre9
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70218841194520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: allowance
|
49
|
-
requirement: &
|
49
|
+
requirement: &70218841193840 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.1.1
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70218841193840
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: happy-cli
|
60
|
-
requirement: &
|
60
|
+
requirement: &70218841193140 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.1.0.pre1
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70218841193140
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &70218841192140 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70218841192140
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70218841189600 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.8'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70218841189600
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec-html-matchers
|
93
|
-
requirement: &
|
93
|
+
requirement: &70218841188740 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70218841188740
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rack-test
|
104
|
-
requirement: &
|
104
|
+
requirement: &70218841187540 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70218841187540
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: watchr
|
115
|
-
requirement: &
|
115
|
+
requirement: &70218841186200 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70218841186200
|
124
124
|
description: A happy little toolkit for writing web applications.
|
125
125
|
email:
|
126
126
|
- hendrik@mans.de
|