motion-resource 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +4 -1
- data/lib/motion-resource/base.rb +2 -8
- data/lib/motion-resource/spec_helpers.rb +1 -1
- data/lib/motion-resource/version.rb +1 -1
- data/motion-resource.gemspec +1 -1
- data/spec/motion-resource/base_spec.rb +0 -8
- metadata +61 -53
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,8 @@ Consider this example for a fictional blog API.
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class Post < MotionResource::Base
|
25
|
-
attr_accessor :id
|
25
|
+
attr_accessor :id
|
26
|
+
attribute :user_id, :title, :text
|
26
27
|
|
27
28
|
belongs_to :user
|
28
29
|
|
@@ -30,6 +31,8 @@ Consider this example for a fictional blog API.
|
|
30
31
|
self.member_url = "users/:user_id/posts/:id"
|
31
32
|
end
|
32
33
|
|
34
|
+
Only attributes declared with `attribute` are transmitted on save. I.e. attributes declared with `attr_accessor` are considered read-only with respect to the JSON API.
|
35
|
+
|
33
36
|
Now, we can access a user's posts like that:
|
34
37
|
|
35
38
|
User.find(1) do |user|
|
data/lib/motion-resource/base.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
module MotionResource
|
2
2
|
class Base
|
3
|
-
|
4
|
-
|
5
|
-
def self.subclasses
|
6
|
-
@subclasses ||= []
|
7
|
-
end
|
3
|
+
include MotionSupport::DescendantsTracker
|
8
4
|
|
9
|
-
|
10
|
-
self.subclasses << subclass
|
11
|
-
end
|
5
|
+
attr_accessor :id
|
12
6
|
|
13
7
|
def initialize(params = {})
|
14
8
|
@new_record = true
|
data/motion-resource.gemspec
CHANGED
@@ -51,12 +51,4 @@ describe "base" do
|
|
51
51
|
shape1.contents.should == 'something'
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
describe "subclasses" do
|
56
|
-
it "should keep track of subclasses" do
|
57
|
-
MotionResource::Base.subclasses.should.include(Shape)
|
58
|
-
Shape.subclasses.should.include(Rectangle)
|
59
|
-
MotionResource::Base.subclasses.should.not.include(Rectangle)
|
60
|
-
end
|
61
|
-
end
|
62
54
|
end
|
metadata
CHANGED
@@ -1,60 +1,71 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-resource
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Thomas Kadauke
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-05-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: bubble-wrap
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
27
31
|
name: motion-support
|
28
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
29
33
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.2.3
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
38
47
|
name: rake
|
39
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
40
49
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
45
54
|
type: :development
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
48
62
|
description: Access RESTful resources from your iOS app. Inspired by ActiveResource.
|
49
|
-
email:
|
63
|
+
email:
|
50
64
|
- thomas.kadauke@googlemail.com
|
51
65
|
executables: []
|
52
|
-
|
53
66
|
extensions: []
|
54
|
-
|
55
67
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
68
|
+
files:
|
58
69
|
- .gitignore
|
59
70
|
- Gemfile
|
60
71
|
- README.md
|
@@ -96,38 +107,35 @@ files:
|
|
96
107
|
- spec/motion-resource/urls_spec.rb
|
97
108
|
homepage: https://github.com/tkadauke/motion-resource
|
98
109
|
licenses: []
|
99
|
-
|
100
110
|
post_install_message:
|
101
111
|
rdoc_options: []
|
102
|
-
|
103
|
-
require_paths:
|
112
|
+
require_paths:
|
104
113
|
- lib
|
105
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
115
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
112
121
|
- 0
|
113
|
-
|
114
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
hash: -124098762633124978
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
124
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
segments:
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
segments:
|
121
130
|
- 0
|
122
|
-
|
131
|
+
hash: -124098762633124978
|
123
132
|
requirements: []
|
124
|
-
|
125
133
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
134
|
+
rubygems_version: 1.8.25
|
127
135
|
signing_key:
|
128
136
|
specification_version: 3
|
129
137
|
summary: Access RESTful resources from your iOS app
|
130
|
-
test_files:
|
138
|
+
test_files:
|
131
139
|
- spec/env.rb
|
132
140
|
- spec/motion-resource/associations/belongs_to_spec.rb
|
133
141
|
- spec/motion-resource/associations/has_many_spec.rb
|