Class: FBGraph::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/fbgraph/base.rb
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
Constructor Details
- (Base) initialize(client)
7
8
9
10
11
|
# File 'lib/fbgraph/base.rb', line 7
def initialize(client)
@client = client
@fields = []
@params = {}
end
|
Instance Attribute Details
- (Object) connection_type
Returns the value of attribute connection_type
5
6
7
|
# File 'lib/fbgraph/base.rb', line 5
def connection_type
@connection_type
end
|
- (Object) last_result
Returns the value of attribute last_result
5
6
7
|
# File 'lib/fbgraph/base.rb', line 5
def last_result
@last_result
end
|
- (Object) logger
Returns the value of attribute logger
5
6
7
|
# File 'lib/fbgraph/base.rb', line 5
def logger
@logger
end
|
- (Object) objects
Returns the value of attribute objects
5
6
7
|
# File 'lib/fbgraph/base.rb', line 5
def objects
@objects
end
|
Instance Method Details
- (Object) connection(connection_type)
18
19
20
21
|
# File 'lib/fbgraph/base.rb', line 18
def connection(connection_type)
@connection_type = connection_type
return self
end
|
- (Object) debug=(att)
92
93
94
|
# File 'lib/fbgraph/base.rb', line 92
def debug=(att)
@debug= att
end
|
- (Object) delete!(parsed = true, &block)
73
74
75
76
77
78
79
80
81
|
# File 'lib/fbgraph/base.rb', line 73
def delete!(parsed = true, &block)
self.instance_eval(&block) if block_given?
@path = build_open_graph_path(@objects , nil)
@params.merge!(:access_token => @client.access_token) if (@client.access_token)
@params.merge!(:method => :delete)
show_log('DELETE' , @path, @params) if @debug
result = @client.consumer[@path].post(@params)
@last_result = ::FBGraph::Result.new(result, @params)
end
|
- (Object) find(objects)
13
14
15
16
|
# File 'lib/fbgraph/base.rb', line 13
def find(objects)
@objects = objects
return self
end
|
- (Object) info!(parsed = true, &block)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fbgraph/base.rb', line 44
def info!(parsed = true, &block)
self.instance_eval(&block) if block_given?
@params.merge!(:fields => sanitized_fields.join(',')) unless sanitized_fields.blank?
@params.merge!(:access_token => @client.access_token) unless @client.access_token.nil?
if @objects.is_a? Array
@params.merge!({:ids => @objects.join(',')})
path = build_open_graph_path(nil,nil, @params)
elsif @objects.is_a? String
path = build_open_graph_path(@objects , @connection_type, @params)
else
raise "No Facebook objects were recognized as selected; unable to build fb graph path."
end
show_log('GET' , path, @params) if @debug
result = @client.consumer[path].get
@last_result = ::FBGraph::Result.new(result, @params)
end
|
- (Object) param(pm)
32
33
34
35
|
# File 'lib/fbgraph/base.rb', line 32
def param(pm)
@params.merge!(pm)
return self
end
|
- (Object) params
28
29
30
|
# File 'lib/fbgraph/base.rb', line 28
def params
@params
end
|
- (Object) params=(ps)
23
24
25
26
|
# File 'lib/fbgraph/base.rb', line 23
def params=(ps)
@params = ps
return self
end
|
- (Object) publish!(data = {}, parsed = true, &block)
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fbgraph/base.rb', line 62
def publish!(data = {},parsed = true, &block)
@params.merge!(data)
self.instance_eval(&block) if block_given?
@params.merge!(:fields => sanitized_fields.join(',')) unless sanitized_fields.blank?
@params.merge!(:access_token => @client.access_token) if (@client.access_token)
@path = build_open_graph_path(@objects , @connection_type)
show_log('POST' , @path, @params) if @debug
result = @client.consumer[@path].post(@params)
@last_result = ::FBGraph::Result.new(result, @params)
end
|
- (Object) with_fields(*new_fields)
Also known as:
fields
37
38
39
40
41
|
# File 'lib/fbgraph/base.rb', line 37
def with_fields(*new_fields)
@fields.concat(new_fields) if !(new_fields.blank? rescue true)
@fields = sanitized_fields
self
end
|