Class: MageHand::WikiPage
- Inherits:
-
Base
- Object
- Base
- MageHand::WikiPage
show all
- Defined in:
- lib/ob_port/wiki_page.rb
Constant Summary
collapse
- ROLES =
{'game_master' => 'Game Master', 'player' => 'Player'}
Instance Attribute Summary
Attributes inherited from Base
#client
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
attr_array, attr_instance, attr_simple, attributes, #attributes, #inflate, inflate_if_nil, #initialize, instance_attributes, #instance_attributes, model_name, #simple_attributes, simple_attributes, #update_attributes!
Constructor Details
This class inherits a constructor from MageHand::Base
Class Method Details
.load_wiki_pages(campaign) ⇒ Object
22
23
24
25
|
# File 'lib/ob_port/wiki_page.rb', line 22
def self.load_wiki_pages(campaign)
wiki_hashes = JSON.parse(campaign.client.access_token.get(collection_url(campaign.id)).body)
wiki_hashes.map {|hash| WikiPage.new(campaign.client, hash)}
end
|
Instance Method Details
#campaign=(campaign_hash) ⇒ Object
27
28
29
|
# File 'lib/ob_port/wiki_page.rb', line 27
def campaign=(campaign_hash)
@campaign = Campaign.new(client, campaign_hash)
end
|
#is_post? ⇒ Boolean
31
32
33
|
# File 'lib/ob_port/wiki_page.rb', line 31
def is_post?
type == 'Post'
end
|
#save! ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/ob_port/wiki_page.rb', line 48
def save!
if id
else puts '#########'
puts client.logged_in?
puts self.campaign.inspect
puts self.class.collection_url(self.campaign.id)
puts client.access_token.inspect
puts client.campaign(self.campaign.id).name
json_body = {'wiki_page' => self.to_hash}.to_json
puts json_body
@response = client.access_token.post(self.class.collection_url(self.campaign.id),
json_body, {'content-type' => 'application/x-www-form-urlencoded'})
puts @response.inspect
puts @response.message
puts @response.body
self.update_attributes!(JSON.parse(@response.body))
end
end
|
#to_hash ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/ob_port/wiki_page.rb', line 35
def to_hash
attribute_hash = {}
simple_attributes.each do |att|
attribute_hash[att] = self.send(att) unless self.send(att).nil?
end
attribute_hash
end
|
#to_json ⇒ Object
44
45
46
|
# File 'lib/ob_port/wiki_page.rb', line 44
def to_json
to_hash.to_json
end
|