benhoskings-hammock 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == 0.2.10 2009-03-17
2
+ Added AR::Base.suggest_scope for narrowing the scope in the suggest action.
3
+ Changed identifier in AR::Base#concise_inspect from #id to #to_param.
4
+ Fixed raise condition for entities arg to RouteNode#for, and improved exception message.
5
+ Changed squash! to compact! in route_for, to only remove nil elements (and not, say, models with no records that respond true to bla
6
+
7
+
1
8
  == 0.2.9 2009-03-13
2
9
  Updated partial_exists? to default format to the current request format instead of html, and accept format instead of extension as a parameter.
3
10
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hammock}
5
- s.version = "0.2.9"
5
+ s.version = "0.2.10"
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-03-13}
9
+ s.date = %q{2009-03-17}
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"]
@@ -8,7 +8,7 @@ Dir.glob("#{File.dirname __FILE__}/hammock/**/*.rb").each {|dep|
8
8
  } if defined?(RAILS_ROOT) # Loading Hammock components under 'rake package' fails.
9
9
 
10
10
  module Hammock
11
- VERSION = '0.2.9'
11
+ VERSION = '0.2.10'
12
12
 
13
13
  def self.included base # :nodoc:
14
14
  Hammock.constants.map {|constant_name|
@@ -104,7 +104,7 @@ module Hammock
104
104
  module InstanceMethods
105
105
 
106
106
  def concise_inspect
107
- "#{self.class}<#{self.id || 'new'}>"
107
+ "#{self.class}<#{self.to_param || 'new'}>"
108
108
  end
109
109
 
110
110
  def resource
@@ -15,6 +15,10 @@ module Hammock
15
15
  nil
16
16
  end
17
17
 
18
+ def suggest_scope
19
+ mdl.readable_by current_user
20
+ end
21
+
18
22
  def postsave_render result
19
23
  nil
20
24
  end
@@ -118,7 +118,9 @@ module Hammock
118
118
  fields = params[:fields].split(',')
119
119
  @queries = params[:q].downcase.split(/\s+/)
120
120
 
121
- mdl.suggest fields, @queries
121
+ mdl.send :with_scope, :find => suggest_scope.to_hash do
122
+ mdl.suggest fields, @queries
123
+ end
122
124
  end
123
125
 
124
126
  if @results.nil?
@@ -141,7 +141,7 @@ module Hammock
141
141
 
142
142
  # TODO process /^creating_\w+_id$/ as well
143
143
  def set_creator_id_if_appropriate
144
- if @record.respond_to?(:creator_id=)
144
+ if @record.respond_to? :creator_id=
145
145
  if current_user.nil?
146
146
  log "Warning: @#{@record.base_model}.creator_id isn't being set, since current_user was nil."
147
147
  else
@@ -24,7 +24,7 @@ module Hammock
24
24
  end
25
25
 
26
26
  def route_for *args
27
- args.squash!
27
+ args.compact!
28
28
  opts = args.extract_options!
29
29
  verb = args.shift if args.first.is_a?(Symbol)
30
30
 
@@ -42,7 +42,7 @@ module Hammock
42
42
 
43
43
  def for verb, entities, options
44
44
  raise "Hammock::RouteNode#for requires an explicitly specified verb as its first argument." unless verb.is_a?(Symbol)
45
- raise "You have to supply an Array of at least one record or resource." if entities.empty? unless entities.is_a?(Array)
45
+ raise "Hammock::RouteNode#for requires an Array of at least one record or resource." if entities.empty? || !entities.is_a?(Array)
46
46
 
47
47
  entity = entities.shift
48
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benhoskings-hammock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
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-03-13 00:00:00 -07:00
12
+ date: 2009-03-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency