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'}
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_id) ⇒ Object
22
23
24
25
26
|
# File 'lib/ob_port/wiki_page.rb', line 22
def self.load_wiki_pages(campaign_id)
wiki_hashes = JSON.parse(
MageHand::get_client.access_token.get(collection_url(campaign_id)).body)
wiki_hashes.map {|hash| WikiPage.new(hash)}
end
|
Instance Method Details
#campaign=(campaign_hash) ⇒ Object
28
29
30
|
# File 'lib/ob_port/wiki_page.rb', line 28
def campaign=(campaign_hash)
@campaign ||= Campaign.new(campaign_hash)
end
|
#is_post? ⇒ Boolean
32
33
34
|
# File 'lib/ob_port/wiki_page.rb', line 32
def is_post?
type == 'Post'
end
|
#save! ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/ob_port/wiki_page.rb', line 49
def save!
if id
else json_body = {'wiki_page' => self.to_hash}.to_json
@response = MageHand.get_client.access_token.post(self.class.collection_url(self.campaign.id),
json_body, {'content-type' => 'application/x-www-form-urlencoded'})
self.update_attributes!(JSON.parse(@response.body))
end
end
|
#to_hash ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/ob_port/wiki_page.rb', line 36
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
45
46
47
|
# File 'lib/ob_port/wiki_page.rb', line 45
def to_json
to_hash.to_json
end
|