mogli 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mogli/client.rb +4 -2
- data/lib/mogli/event.rb +1 -0
- data/lib/mogli/model.rb +7 -5
- data/lib/mogli/user.rb +4 -1
- metadata +2 -2
data/lib/mogli/client.rb
CHANGED
@@ -47,8 +47,8 @@ module Mogli
|
|
47
47
|
self.class.delete(api_path(path),:query=>default_params)
|
48
48
|
end
|
49
49
|
|
50
|
-
def get_and_map(path,klass=nil)
|
51
|
-
data = self.class.get(api_path(path),:query=>default_params)
|
50
|
+
def get_and_map(path,klass=nil,body_args = {})
|
51
|
+
data = self.class.get(api_path(path),:query=>default_params.merge(body_args))
|
52
52
|
map_data(data,klass)
|
53
53
|
end
|
54
54
|
|
@@ -67,6 +67,7 @@ module Mogli
|
|
67
67
|
#protected
|
68
68
|
|
69
69
|
def extract_hash_or_array(hash_or_array,klass)
|
70
|
+
return nil if hash_or_array == false
|
70
71
|
return hash_or_array if hash_or_array.nil? or hash_or_array.kind_of?(Array)
|
71
72
|
return extract_fetching_array(hash_or_array,klass) if hash_or_array.has_key?("data")
|
72
73
|
return hash_or_array
|
@@ -85,6 +86,7 @@ module Mogli
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def map_to_class(hash_or_array,klass)
|
89
|
+
return nil if hash_or_array.nil?
|
88
90
|
if hash_or_array.kind_of?(Array)
|
89
91
|
hash_or_array.map! {|i| create_instance(klass,i)}
|
90
92
|
else
|
data/lib/mogli/event.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Mogli
|
2
2
|
class Event < Model
|
3
3
|
define_properties :id, :name, :description, :start_time, :end_time, :location, :privacy, :updated_time
|
4
|
+
creation_properties :start_time, :end_time, :link, :name, :description, :privacy
|
4
5
|
|
5
6
|
hash_populating_accessor :venue, "Address"
|
6
7
|
hash_populating_accessor :owner, "User", "Page"
|
data/lib/mogli/model.rb
CHANGED
@@ -77,9 +77,10 @@ module Mogli
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def self.has_association(name,klass)
|
80
|
-
define_method name do
|
80
|
+
define_method name do |*fields|
|
81
|
+
body_args = fields.empty? ? {} : {:fields => fields}
|
81
82
|
if (ret=instance_variable_get("@#{name}")).nil?
|
82
|
-
ret = client.get_and_map("#{id}/#{name}",klass)
|
83
|
+
ret = client.get_and_map("#{id}/#{name}",klass, body_args)
|
83
84
|
instance_variable_set("@#{name}",ret)
|
84
85
|
end
|
85
86
|
return ret
|
@@ -88,7 +89,7 @@ module Mogli
|
|
88
89
|
add_creation_method(name,klass)
|
89
90
|
end
|
90
91
|
|
91
|
-
def fetch
|
92
|
+
def fetch()
|
92
93
|
raise ArgumentError.new("You cannot fetch models without a populated id attribute") if id.nil?
|
93
94
|
other = self.class.find(id,client)
|
94
95
|
merge!(other)
|
@@ -98,8 +99,9 @@ module Mogli
|
|
98
99
|
true
|
99
100
|
end
|
100
101
|
|
101
|
-
def self.find(id,client=nil)
|
102
|
-
|
102
|
+
def self.find(id,client=nil, *fields)
|
103
|
+
body_args = fields.empty? ? {} : {:fields => fields}
|
104
|
+
(client||Mogli::Client.new).get_and_map(id,self, body_args)
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
data/lib/mogli/user.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Mogli
|
3
3
|
class User < Profile
|
4
4
|
|
5
|
-
define_properties :first_name, :last_name, :link, :about, :birthday,
|
5
|
+
define_properties :first_name, :last_name, :link, :about, :birthday, :gender,
|
6
6
|
:email, :website, :timezone, :updated_time, :verified
|
7
7
|
|
8
8
|
def self.recognize?(hash)
|
@@ -11,6 +11,9 @@ module Mogli
|
|
11
11
|
|
12
12
|
hash_populating_accessor :work, "Work"
|
13
13
|
hash_populating_accessor :education, "Education"
|
14
|
+
|
15
|
+
hash_populating_accessor :location, "Page"
|
16
|
+
hash_populating_accessor :hometown, "Page"
|
14
17
|
|
15
18
|
has_association :activities,"Activity"
|
16
19
|
has_association :friends, "User"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Mangino
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-05-
|
12
|
+
date: 2010-05-26 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|