hammock 0.2.12 → 0.2.12.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/hammock.gemspec +2 -2
- data/lib/hammock/scope.rb +13 -13
- data/lib/hammock.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/hammock.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{hammock}
|
5
|
-
s.version = "0.2.12"
|
5
|
+
s.version = "0.2.12.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ben Hoskings"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-04-01}
|
10
10
|
s.description = %q{Hammock is a Rails plugin that eliminates redundant code in a very RESTful manner. It does this in lots in lots of different places, but in one manner: it encourages specification in place of implementation. Hammock enforces RESTful resource access by abstracting actions away from the controller in favour of a clean, model-like callback system. Hammock tackles the hard and soft sides of security at once with a scoping security system on your models. Specify who can verb what resources under what conditions once, and everything else - the actual security, link generation, index filtering - just happens. Hammock inspects your routes and resources to generate a routing tree for each resource. Parent resources in a nested route are handled transparently at every point - record retrieval, creation, and linking. It makes more sense when you see how it works though, so check out the screencast!}
|
11
11
|
s.email = ["ben@hoskings.net"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc", "misc/scaffold.txt"]
|
data/lib/hammock/scope.rb
CHANGED
@@ -27,13 +27,13 @@ module Hammock
|
|
27
27
|
raise "The verb at #{call_point} must be supplied as a Symbol." unless verb.nil? || verb.is_a?(Symbol)
|
28
28
|
route = route_for verb, resource
|
29
29
|
if route.safe? && !resource.indexable_by(current_user)
|
30
|
-
|
30
|
+
dlog "#{requester_name} can't index #{resource.name.pluralize}. #{describe_call_point 4}"
|
31
31
|
:not_found
|
32
32
|
elsif !route.safe? && !make_createable(resource)
|
33
|
-
|
33
|
+
dlog "#{requester_name} can't #{verb} #{resource.name.pluralize}. #{describe_call_point 4}"
|
34
34
|
:read_only
|
35
35
|
else
|
36
|
-
#
|
36
|
+
# dlog "#{requester_name} can #{verb} #{resource.name.pluralize}."
|
37
37
|
:ok
|
38
38
|
end
|
39
39
|
end
|
@@ -43,20 +43,20 @@ module Hammock
|
|
43
43
|
route = route_for verb, record
|
44
44
|
if route.verb.in?(:save, :create) && record.new_record?
|
45
45
|
if !record.createable_by?(current_user)
|
46
|
-
|
46
|
+
dlog "#{requester_name} can't create a #{record.class} with #{record.attributes.inspect}. #{describe_call_point 4}"
|
47
47
|
:unauthed
|
48
48
|
else
|
49
49
|
:ok
|
50
50
|
end
|
51
51
|
else
|
52
52
|
if !record.readable_by?(current_user)
|
53
|
-
|
53
|
+
dlog "#{requester_name} can't see #{record.class}<#{record.id}>. #{describe_call_point 4}"
|
54
54
|
:not_found
|
55
55
|
elsif !route.safe? && !record.writeable_by?(current_user)
|
56
|
-
|
56
|
+
dlog "#{requester_name} can't #{verb} #{record.class}<#{record.id}>. #{describe_call_point 4}"
|
57
57
|
:read_only
|
58
58
|
else
|
59
|
-
#
|
59
|
+
# dlog "#{requester_name} can #{verb} #{record.class}<#{record.id}>."
|
60
60
|
:ok
|
61
61
|
end
|
62
62
|
end
|
@@ -64,13 +64,13 @@ module Hammock
|
|
64
64
|
|
65
65
|
def current_verb_scope
|
66
66
|
if current_user && (scope_name = account_verb_scope?)
|
67
|
-
#
|
67
|
+
# dlog "got an account_verb_scope #{scope_name}."
|
68
68
|
mdl.send scope_name, current_user
|
69
69
|
elsif !(scope_name = public_verb_scope?)
|
70
70
|
log "No #{current_user.nil? ? 'public' : 'account'} #{scope_name_for_action} scope available for #{mdl}.#{' May be available after login.' if account_verb_scope?}"
|
71
71
|
nil
|
72
72
|
else
|
73
|
-
#
|
73
|
+
# dlog "got a #{scope_name} public_verb_scope."
|
74
74
|
mdl.send scope_name
|
75
75
|
end
|
76
76
|
end
|
@@ -84,15 +84,15 @@ module Hammock
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def current_scope
|
87
|
-
|
87
|
+
dlog "#{current_hammock_resource.mdl}, #{current_hammock_resource.ancestry.map(&:mdl).inspect}"
|
88
88
|
if (verb_scope = current_verb_scope).nil?
|
89
89
|
nil
|
90
90
|
elsif (resultant_scope = verb_scope.within(current_nest_scope, current_hammock_resource.routing_parent)).nil?
|
91
91
|
nil
|
92
92
|
else
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
93
|
+
# dlog "nest: #{current_nest_scope.clauses.inspect}"
|
94
|
+
# dlog "verb: #{current_verb_scope.clauses.inspect}"
|
95
|
+
dlog "chained in (#{resultant_scope.owner}) current_scope: #{resultant_scope.clauses.inspect}"
|
96
96
|
resultant_scope = resultant_scope.chain(custom_scope) unless custom_scope.nil?
|
97
97
|
resultant_scope.sort_by &mdl.sorter
|
98
98
|
end
|
data/lib/hammock.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.12
|
4
|
+
version: 0.2.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Hoskings
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-01 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|