activeresource 3.0.0.beta → 3.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeresource might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,4 +1,4 @@
1
- *Edge*
1
+ *Rails 3.0.0 [beta 1] (February 4, 2010)*
2
2
 
3
3
  * Add support for errors in JSON format. #1956 [Fabien Jakimowicz]
4
4
 
@@ -9,6 +9,7 @@ require 'active_support/core_ext/module/aliasing'
9
9
  require 'active_support/core_ext/object/blank'
10
10
  require 'active_support/core_ext/object/misc'
11
11
  require 'active_support/core_ext/object/to_query'
12
+ require 'active_support/core_ext/object/duplicable'
12
13
  require 'set'
13
14
  require 'uri'
14
15
 
@@ -625,6 +626,22 @@ module ActiveResource
625
626
  "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}"
626
627
  end
627
628
 
629
+ # Gets the new element path for REST resources.
630
+ #
631
+ # ==== Options
632
+ # * +prefix_options+ - A hash to add a prefix to the request for nested URLs (e.g., <tt>:account_id => 19</tt>
633
+ # would yield a URL like <tt>/accounts/19/purchases/new.xml</tt>).
634
+ #
635
+ # ==== Examples
636
+ # Post.new_element_path
637
+ # # => /posts/new.xml
638
+ #
639
+ # Comment.collection_path(:post_id => 5)
640
+ # # => /posts/5/comments/new.xml
641
+ def new_element_path(prefix_options = {})
642
+ "#{prefix(prefix_options)}#{collection_name}/new.#{format.extension}"
643
+ end
644
+
628
645
  # Gets the collection path for the REST resources. If the +query_options+ parameter is omitted, Rails
629
646
  # will split from the +prefix_options+.
630
647
  #
@@ -653,6 +670,19 @@ module ActiveResource
653
670
 
654
671
  alias_method :set_primary_key, :primary_key= #:nodoc:
655
672
 
673
+ # Builds a new, unsaved record using the default values from the remote server so
674
+ # that it can be used with RESTful forms.
675
+ #
676
+ # ==== Options
677
+ # * +attributes+ - A hash that overrides the default values from the server.
678
+ #
679
+ # Returns the new resource instance.
680
+ #
681
+ def build(attributes = {})
682
+ attrs = connection.get("#{new_element_path}").merge(attributes)
683
+ self.new(attrs)
684
+ end
685
+
656
686
  # Creates a new resource instance and makes a request to the remote service
657
687
  # that it be saved, making it equivalent to the following simultaneous calls:
658
688
  #
@@ -989,6 +1019,22 @@ module ActiveResource
989
1019
  end
990
1020
  alias :new_record? :new?
991
1021
 
1022
+ # Returns +true+ if this object has been saved, otherwise returns +false+.
1023
+ #
1024
+ # ==== Examples
1025
+ # persisted = Computer.create(:brand => 'Apple', :make => 'MacBook', :vendor => 'MacMall')
1026
+ # persisted.persisted? # => true
1027
+ #
1028
+ # not_persisted = Computer.new(:brand => 'IBM', :make => 'Thinkpad', :vendor => 'IBM')
1029
+ # not_persisted.persisted? # => false
1030
+ #
1031
+ # not_persisted.save
1032
+ # not_persisted.persisted? # => true
1033
+ #
1034
+ def persisted?
1035
+ !new?
1036
+ end
1037
+
992
1038
  # Gets the <tt>\id</tt> attribute of the resource.
993
1039
  def id
994
1040
  attributes[self.class.primary_key]
@@ -1346,6 +1392,10 @@ module ActiveResource
1346
1392
  self.class.element_path(to_param, options || prefix_options)
1347
1393
  end
1348
1394
 
1395
+ def new_element_path
1396
+ self.class.new_element_path(prefix_options)
1397
+ end
1398
+
1349
1399
  def collection_path(options = nil)
1350
1400
  self.class.collection_path(options || prefix_options)
1351
1401
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  module ActiveResource
2
4
  # A module to support custom REST methods and sub-resources, allowing you to break out
3
5
  # of the "default" REST methods with your own custom resource requests. For example,
@@ -3,10 +3,10 @@ require "rails"
3
3
 
4
4
  module ActiveResource
5
5
  class Railtie < Rails::Railtie
6
- railtie_name :active_resource
6
+ config.active_resource = ActiveSupport::OrderedOptions.new
7
7
 
8
- require "active_resource/railties/subscriber"
9
- subscriber ActiveResource::Railties::Subscriber.new
8
+ require "active_resource/railties/log_subscriber"
9
+ log_subscriber :active_resource, ActiveResource::Railties::LogSubscriber.new
10
10
 
11
11
  initializer "active_resource.set_configs" do |app|
12
12
  app.config.active_resource.each do |k,v|
@@ -1,6 +1,6 @@
1
1
  module ActiveResource
2
2
  module Railties
3
- class Subscriber < Rails::Subscriber
3
+ class LogSubscriber < Rails::LogSubscriber
4
4
  def request(event)
5
5
  result = event.payload[:result]
6
6
  info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}"
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/array/wrap'
2
+ require 'active_support/core_ext/object/blank'
2
3
 
3
4
  module ActiveResource
4
5
  class ResourceInvalid < ClientError #:nodoc:
@@ -2,8 +2,9 @@ module ActiveResource
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = "0.beta"
5
+ TINY = 0
6
+ BUILD = "beta2"
6
7
 
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
+ STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
8
9
  end
9
10
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta
4
+ prerelease: true
5
+ segments:
6
+ - 3
7
+ - 0
8
+ - 0
9
+ - beta2
10
+ version: 3.0.0.beta2
5
11
  platform: ruby
6
12
  authors:
7
13
  - David Heinemeier Hansson
@@ -9,30 +15,40 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-04 00:00:00 -08:00
18
+ date: 2010-04-01 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
20
25
  requirements:
21
26
  - - "="
22
27
  - !ruby/object:Gem::Version
23
- version: 3.0.0.beta
24
- version:
28
+ segments:
29
+ - 3
30
+ - 0
31
+ - 0
32
+ - beta2
33
+ version: 3.0.0.beta2
34
+ type: :runtime
35
+ version_requirements: *id001
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: activemodel
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
30
40
  requirements:
31
41
  - - "="
32
42
  - !ruby/object:Gem::Version
33
- version: 3.0.0.beta
34
- version:
35
- description: REST-model framework (part of Rails).
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ - beta2
48
+ version: 3.0.0.beta2
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.
36
52
  email: david@loudthinking.com
37
53
  executables: []
38
54
 
@@ -54,7 +70,7 @@ files:
54
70
  - lib/active_resource/http_mock.rb
55
71
  - lib/active_resource/observing.rb
56
72
  - lib/active_resource/railtie.rb
57
- - lib/active_resource/railties/subscriber.rb
73
+ - lib/active_resource/railties/log_subscriber.rb
58
74
  - lib/active_resource/schema.rb
59
75
  - lib/active_resource/validations.rb
60
76
  - lib/active_resource/version.rb
@@ -73,20 +89,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
89
  requirements:
74
90
  - - ">="
75
91
  - !ruby/object:Gem::Version
76
- version: "0"
77
- version:
92
+ segments:
93
+ - 1
94
+ - 8
95
+ - 7
96
+ version: 1.8.7
78
97
  required_rubygems_version: !ruby/object:Gem::Requirement
79
98
  requirements:
80
99
  - - ">"
81
100
  - !ruby/object:Gem::Version
101
+ segments:
102
+ - 1
103
+ - 3
104
+ - 1
82
105
  version: 1.3.1
83
- version:
84
106
  requirements: []
85
107
 
86
108
  rubyforge_project: activeresource
87
- rubygems_version: 1.3.5
109
+ rubygems_version: 1.3.6
88
110
  signing_key:
89
111
  specification_version: 3
90
- summary: REST-model framework (part of Rails).
112
+ summary: REST modeling framework (part of Rails).
91
113
  test_files: []
92
114