hammock 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/hammock.gemspec +2 -2
- data/lib/hammock/ajaxinate.rb +1 -1
- data/lib/hammock/monkey_patches/active_record.rb +2 -1
- data/lib/hammock/monkey_patches/object.rb +6 -1
- data/lib/hammock/resource_retrieval.rb +1 -1
- data/lib/hammock/restful_support.rb +10 -12
- data/lib/hammock/scope.rb +2 -2
- data/public/javascripts/ajax.js +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 0.5.7 2010-02-21
|
2
|
+
Flatten resource lists instead of splatting, to avoid implicit #to_a on Ambition contexts.
|
3
|
+
Don't eval JS responses in the XHR callback, since it already happens automatically.
|
4
|
+
|
5
|
+
|
1
6
|
== 0.5.6 2010-01-07
|
2
7
|
Fixed Hammock.loaded_from_gem? to work for any gem path, not just `gem env gemdir`.
|
3
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.7
|
data/hammock.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hammock}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Hoskings"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-21}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{ben@hoskings.net}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/hammock/ajaxinate.rb
CHANGED
@@ -70,7 +70,7 @@ module Hammock
|
|
70
70
|
subclasses.each &:reset_cached_column_info
|
71
71
|
end
|
72
72
|
|
73
|
-
def find_or_new_with(find_attributes, create_attributes = {})
|
73
|
+
def find_or_new_with(find_attributes, create_attributes = {}, should_assign = false)
|
74
74
|
finder = respond_to?(:find_with_destroyed) ? :find_with_destroyed : :find
|
75
75
|
|
76
76
|
if record = send(finder, :first, :conditions => find_attributes.discard(:deleted_at))
|
@@ -80,6 +80,7 @@ module Hammock
|
|
80
80
|
# (c) it is deleted, but we want to find one that's deleted, or
|
81
81
|
# (d) we don't want a deleted record, and undestruction succeeds.
|
82
82
|
if (finder != :find_with_destroyed) || !record.deleted? || create_attributes[:deleted_at] || record.restore
|
83
|
+
record.attributes = create_attributes if should_assign
|
83
84
|
record
|
84
85
|
end
|
85
86
|
else
|
@@ -73,18 +73,16 @@ module Hammock
|
|
73
73
|
merge(params_for(resource.symbolize))
|
74
74
|
end
|
75
75
|
|
76
|
-
def assign_entity
|
77
|
-
@entity = if
|
78
|
-
|
79
|
-
elsif
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
instance_variable_set "@#{mdl_name.pluralize}", (@records =
|
84
|
-
elsif
|
85
|
-
|
86
|
-
else
|
87
|
-
raise "Unknown record(s) type #{record_or_records.class}."
|
76
|
+
def assign_entity entity
|
77
|
+
@entity = if entity.is_a? ActiveRecord::Base
|
78
|
+
instance_variable_set "@#{mdl_name}", (@record = entity)
|
79
|
+
elsif entity.is_a? Ambition::Context
|
80
|
+
# log "Unkicked query: #{entity.to_hash.inspect}"
|
81
|
+
instance_variable_set "@#{mdl_name.pluralize}", (@records = entity)
|
82
|
+
elsif entity.is_a? Array
|
83
|
+
instance_variable_set "@#{mdl_name.pluralize}", (@records = entity)
|
84
|
+
elsif !entity.nil?
|
85
|
+
raise "Unknown record(s) type #{entity.class}."
|
88
86
|
end
|
89
87
|
|
90
88
|
@entity if assign_nesting_entities
|
data/lib/hammock/scope.rb
CHANGED
@@ -45,11 +45,11 @@ module Hammock
|
|
45
45
|
route = route_for verb, *entities
|
46
46
|
if route.verb.in?(:save, :create) && record.new_record?
|
47
47
|
returning record.createable_by?(current_user) ? :ok : :unauthed do |result|
|
48
|
-
dlog "#{requester_name} can#{"'t" unless result == :ok} create a #{record.class} with #{record.attributes.inspect}. #{describe_call_point 4}"
|
48
|
+
# dlog "#{requester_name} can#{"'t" unless result == :ok} create a #{record.class} with #{record.attributes.inspect}. #{describe_call_point 4}"
|
49
49
|
end
|
50
50
|
else
|
51
51
|
returning record_in_scope?(route, record) ? :ok : :not_found do |result|
|
52
|
-
dlog "#{requester_name} can#{"'t" unless result == :ok} #{verb} #{record.class}<#{record.id}>. #{describe_call_point 4}"
|
52
|
+
# dlog "#{requester_name} can#{"'t" unless result == :ok} #{verb} #{record.class}<#{record.id}>. #{describe_call_point 4}"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/public/javascripts/ajax.js
CHANGED
@@ -52,7 +52,7 @@ var fire_hammock_ajax = function(data) {
|
|
52
52
|
),
|
53
53
|
function(response, textStatus) {
|
54
54
|
if (data.format == 'js') {
|
55
|
-
|
55
|
+
// JS responses are evaluated automatically
|
56
56
|
} else {
|
57
57
|
jQuery('.' + (data.target || data.klass + '_target')).before(response).remove();
|
58
58
|
}
|
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.5.
|
4
|
+
version: 0.5.7
|
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: 2010-
|
12
|
+
date: 2010-02-21 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|