mogli 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mogli.rb +0 -1
- data/lib/mogli/model.rb +28 -11
- metadata +5 -21
data/lib/mogli.rb
CHANGED
data/lib/mogli/model.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'mogli/model/search'
|
2
2
|
|
3
3
|
module Mogli
|
4
|
-
class Model
|
4
|
+
class Model
|
5
5
|
extend Mogli::Model::Search
|
6
6
|
|
7
7
|
set_search_type :all
|
@@ -17,25 +17,25 @@ module Mogli
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize(hash={},client=nil)
|
20
|
+
@_values = {}
|
20
21
|
self.client=client
|
21
|
-
|
22
|
+
hash.each do |k,v|
|
23
|
+
self.send("#{k}=",v)
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
def post_params
|
25
28
|
post_params = {}
|
26
29
|
self.class.creation_keys.each do |key|
|
27
|
-
post_params[key] =
|
30
|
+
post_params[key] = @_values[key.to_s]
|
28
31
|
|
29
32
|
# make sure actions and any other creation_properties that aren't just
|
30
33
|
# hash entries get added...
|
31
|
-
if post_params[key].nil? &&
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
post_params[key] = if val.respond_to?(:to_json)
|
34
|
+
if post_params[key].nil? && self.respond_to?(key.to_sym) && !(val=self.send(key.to_sym)).nil?
|
35
|
+
post_params[key] = if val.is_a?(Array)
|
36
|
+
"[#{val.map { |v| v.respond_to?(:to_json) ? v.to_json : nil }.compact.join(',')}]"
|
37
|
+
elsif val.respond_to?(:to_json)
|
36
38
|
val.to_json
|
37
|
-
elsif val.is_a?(Array)
|
38
|
-
"[#{val.map { |v| v.respond_to?(:to_json) ? v.to_json : nil }.compact.join(',')}]"
|
39
39
|
else
|
40
40
|
nil
|
41
41
|
end
|
@@ -66,6 +66,19 @@ module Mogli
|
|
66
66
|
puts "Warning: property #{property} doesn't exist for class #{self.class.name}"
|
67
67
|
end
|
68
68
|
|
69
|
+
def self.property(arg)
|
70
|
+
@properties ||= []
|
71
|
+
@properties << arg
|
72
|
+
define_method arg do
|
73
|
+
@_values[arg.to_s]
|
74
|
+
end
|
75
|
+
define_method "#{arg}=" do |val|
|
76
|
+
@_values[arg.to_s] = val
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
|
69
82
|
def self.define_properties(*args)
|
70
83
|
args.each do |arg|
|
71
84
|
property arg
|
@@ -122,7 +135,11 @@ module Mogli
|
|
122
135
|
other = self.class.find(id,client)
|
123
136
|
merge!(other) if other
|
124
137
|
end
|
125
|
-
|
138
|
+
|
139
|
+
def merge!(other)
|
140
|
+
@_values.merge!(other.instance_variable_get("@_values"))
|
141
|
+
end
|
142
|
+
|
126
143
|
def self.recognize?(data)
|
127
144
|
true
|
128
145
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 24
|
10
|
+
version: 0.0.24
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Mangino
|
@@ -18,26 +18,10 @@ cert_chain: []
|
|
18
18
|
date: 2011-02-01 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: hashie
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 2
|
33
|
-
- 0
|
34
|
-
version: 0.2.0
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
21
|
- !ruby/object:Gem::Dependency
|
38
22
|
name: httparty
|
39
23
|
prerelease: false
|
40
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
42
26
|
requirements:
|
43
27
|
- - ">="
|
@@ -49,7 +33,7 @@ dependencies:
|
|
49
33
|
- 3
|
50
34
|
version: 0.4.3
|
51
35
|
type: :runtime
|
52
|
-
version_requirements: *
|
36
|
+
version_requirements: *id001
|
53
37
|
description: Simple library for accessing the facebook Open Graph API
|
54
38
|
email: mmangino@elevatedrails.com
|
55
39
|
executables: []
|