Class: Muddyit::Sites::Site::Page
- Defined in:
- lib/muddyit/page.rb
Defined Under Namespace
Classes: ContentData
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Generic
Attributes inherited from Base
#access_token, #access_token_secret, #consumer_key, #consumer_secret, #rest_endpoint
Instance Method Summary collapse
-
#content_data ⇒ Object
get content_data for page.
-
#destroy ⇒ Object
delete the page.
-
#initialize(muddyit, attributes = {}) ⇒ Page
constructor
Create a set of entities from the categorisation results.
-
#refresh(options = {}) ⇒ Object
submit a page or text for re-categorisation.
-
#related_content(options = {}) ⇒ Object
retrieve related pages.
Methods inherited from Generic
Methods inherited from Base
Constructor Details
#initialize(muddyit, attributes = {}) ⇒ Page
Create a set of entities from the categorisation results
4 5 6 7 8 |
# File 'lib/muddyit/page.rb', line 4 def initialize(muddyit, attributes = {}) super(muddyit, attributes) create_entities @content_data_cache = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Muddyit::Generic
Instance Method Details
#content_data ⇒ Object
get content_data for page
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/muddyit/page.rb', line 30 def content_data if @content_data_cache.nil? if @attributes[:content_data] @content_data_cache = Muddyit::Sites::Site::Page::ContentData.new(@muddyit, @attributes[:content_data]) else r = self.fetch @content_data_cache = Muddyit::Sites::Site::Page::ContentData.new(@muddyit, r[:content_data]) end end @content_data_cache end |
#destroy ⇒ Object
delete the page
45 46 47 48 49 50 |
# File 'lib/muddyit/page.rb', line 45 def destroy api_url = "/sites/#{self.site.attributes[:token]}/pages/#{URI.escape(CGI.escape(@attributes[:identifier]),'.')}" response = @muddyit.send_request(api_url, :delete, {}) # Is this the correct thing to return ? return true end |
#refresh(options = {}) ⇒ Object
submit a page or text for re-categorisation
Params
-
options (Required)
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/muddyit/page.rb', line 15 def refresh( = {}) # Ensure we get content_data as well [:include_content] = true body = { :page => { :uri => self.uri }, :options => } api_url = "/sites/#{self.site.attributes[:token]}/pages/#{URI.escape(CGI.escape(self.identifier),'.')}" response = @muddyit.send_request(api_url, :put, {}, body.to_json) return Muddyit::Sites::Site::Page.new(@muddyit, response.merge!(:site => self.site)) end |
#related_content(options = {}) ⇒ Object
retrieve related pages
Params
-
options (Optional)
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/muddyit/page.rb', line 57 def ( = {}) api_url = "/sites/#{self.site.attributes[:token]}/pages/#{URI.escape(CGI.escape(@attributes[:identifier]),'.')}/related/content" response = @muddyit.send_request(api_url, :get, ) results = [] response.each { |result| # The return format needs sorting out here ....... results.push :page => @attributes[:site].pages.find(result['identifier']), :count => result['count'] } return results end |