legato 0.0.6 → 0.0.7
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.
- data/lib/legato/model.rb +6 -6
- data/lib/legato/query.rb +4 -0
- data/lib/legato/user.rb +1 -1
- data/lib/legato/version.rb +1 -1
- data/spec/lib/legato/model_spec.rb +10 -0
- data/spec/lib/legato/query_spec.rb +6 -0
- data/spec/lib/legato/user_spec.rb +3 -2
- metadata +4 -4
data/lib/legato/model.rb
CHANGED
@@ -26,13 +26,13 @@ module Legato
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def set_instance_klass(klass)
|
30
|
+
@instance_klass = klass
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def instance_klass
|
34
|
+
@instance_klass || OpenStruct
|
35
|
+
end
|
36
36
|
|
37
37
|
def results(profile, options = {})
|
38
38
|
Query.new(self).results(profile, options)
|
data/lib/legato/query.rb
CHANGED
data/lib/legato/user.rb
CHANGED
data/lib/legato/version.rb
CHANGED
@@ -32,6 +32,16 @@ describe "Legato::Model" do
|
|
32
32
|
@model.dimensions.should == Legato::ListParameter.new(:dimensions, [:browser, :city])
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'knows the instance class it should use' do
|
36
|
+
klass = Class.new
|
37
|
+
@model.set_instance_klass(klass)
|
38
|
+
@model.instance_klass.should == klass
|
39
|
+
end
|
40
|
+
|
41
|
+
it "defaults to OpenStruct for its instance class" do
|
42
|
+
@model.instance_klass.should == OpenStruct
|
43
|
+
end
|
44
|
+
|
35
45
|
context "with filters" do
|
36
46
|
before :each do
|
37
47
|
@block = lambda {}
|
@@ -46,6 +46,12 @@ describe Legato::Query do
|
|
46
46
|
@query.loaded?.should == false
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'delegates the instance klass from the parent klass' do
|
50
|
+
klass = Class.new
|
51
|
+
@query.parent_klass.stubs(:instance_klass).returns(klass)
|
52
|
+
@query.instance_klass.should == klass
|
53
|
+
end
|
54
|
+
|
49
55
|
it "loads a collection of results" do
|
50
56
|
response = stub(:collection => [], :total_results => 0, :totals_for_all_results => {})
|
51
57
|
user = stub(:request => response)
|
@@ -8,12 +8,13 @@ describe Legato::User do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'returns a response for a given query' do
|
11
|
+
klass = Class.new
|
11
12
|
@access_token.stubs(:get).returns('a response')
|
12
13
|
Legato::Response.stubs(:new)
|
13
14
|
|
14
|
-
@user.request(stub(:to_params => "params"))
|
15
|
+
@user.request(stub(:to_params => "params", :instance_klass => klass))
|
15
16
|
|
16
|
-
Legato::Response.should have_received(:new).with('a response')
|
17
|
+
Legato::Response.should have_received(:new).with('a response', klass)
|
17
18
|
@access_token.should have_received(:get).with(Legato::User::URL, :params => "params")
|
18
19
|
end
|
19
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Pitale
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - "="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
hash:
|
83
|
+
hash: -2540839718
|
84
84
|
segments:
|
85
85
|
- 2
|
86
86
|
- 0
|