Class: ActiveTriple::Connectors::PostToUrlConnector
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Instance Attribute Details
#triples ⇒ Object
Returns the value of attribute triples.
8
9
10
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 8
def triples
@triples
end
|
#url_variables ⇒ Object
Returns the value of attribute url_variables.
8
9
10
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 8
def url_variables
@url_variables
end
|
Class Method Details
.send_data(args) ⇒ Object
11
12
13
14
15
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 11
def self.send_data(args)
connector = new
connector.send_by_post(args)
return connector
end
|
Instance Method Details
#path ⇒ Object
38
39
40
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 38
def path
raise 'Need to define path to server'
end
|
#response ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 17
def response
resp = by_post
begin
json = JSON.parse(resp.body)
results = json.first[1]
results.collect!{|a| Hashie::Mash.new(a)}
return results
rescue JSON::ParserError => e
if /No stories found for query/ =~ e.message
return Array.new
else
raise e
end
end
end
|
#send_by_post(args) ⇒ Object
33
34
35
36
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 33
def send_by_post(args)
@triples = args.delete(:triples)
set_url_variables(args)
end
|
#set_url_variables(variables = {}) ⇒ Object
42
43
44
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 42
def set_url_variables(variables = {})
@url_variables = build_varible_string(variables)
end
|
#url ⇒ Object
46
47
48
|
# File 'lib/active_triple/connectors/post_to_url_connector.rb', line 46
def url
[path, url_variables].join
end
|