toast 0.8.7 → 0.8.8

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.
@@ -165,9 +165,18 @@ module Toast
165
165
  link_model = Resource.get_class_by_resource_name(link_resource_name)
166
166
  link_record = link_model.find(link_id)
167
167
 
168
+ reflection = @model.reflect_on_association(@assoc.to_sym)
169
+
168
170
  if @model.reflect_on_association(@assoc.to_sym).collection?
169
171
  # has_many, hbtm
170
- @record.send(@assoc).delete(link_record) unless link_record.nil?
172
+ if( @config.pass_params_to.include?(@assoc) and
173
+ reflection.options[:extend] and
174
+ reflection.options[:extend].detect{|e| e.method_defined? :delete})
175
+
176
+ @record.send(@assoc).delete(link_record,@params)
177
+ else
178
+ @record.send(@assoc).delete(link_record) unless link_record.nil?
179
+ end
171
180
  else
172
181
 
173
182
  # has_one, belongs_to
data/lib/toast/record.rb CHANGED
@@ -3,12 +3,13 @@ module Toast
3
3
 
4
4
  attr_reader :model
5
5
 
6
- def initialize model, id, format, config_in, config_out
6
+ def initialize model, id, format, params, config_in, config_out
7
7
  @model = model
8
8
  @record = model.find(id) rescue raise(ResourceNotFound.new)
9
9
  @format = format
10
10
  @config_in = config_in
11
11
  @config_out = config_out
12
+ @params = params
12
13
  end
13
14
 
14
15
  def post payload, media_type
@@ -51,7 +52,13 @@ module Toast
51
52
  end
52
53
 
53
54
  # mass-update for the rest
54
- @record.update_attributes! payload
55
+ if @config_in.pass_params_to.include? 'self'
56
+ # parameter passing
57
+ @record.update_attributes! payload, @params
58
+ else
59
+ @record.update_attributes! payload
60
+ end
61
+
55
62
  {
56
63
  :json => @record.represent( @config_out.exposed_attributes,
57
64
  @config_out.exposed_associations,
@@ -48,7 +48,7 @@ module Toast
48
48
  elsif id.nil?
49
49
  Toast::Collection.new(model, subresource_name, params.clone, config_in, config_out)
50
50
  elsif subresource_name.nil?
51
- Toast::Record.new(model, id, format, config_in, config_out)
51
+ Toast::Record.new(model, id, format, params.clone, config_in, config_out)
52
52
  elsif (config_assoc_src && config_assoc_src.exposed_associations.include?(subresource_name))
53
53
 
54
54
  # determine associated model
data/lib/toast/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toast
2
- VERSION = '0.8.7'
2
+ VERSION = '0.8.8'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toast
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 7
10
- version: 0.8.7
9
+ - 8
10
+ version: 0.8.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - "robokopp (Robert Anni\xC3\xA9s)"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-05 00:00:00 Z
18
+ date: 2013-01-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails