Class: Muddyit::Sites::Site::Entities::Entity

Inherits:
Generic
  • Object
show all
Defined in:
lib/muddyit/sites/entities/entity.rb

Constant Summary

Constants inherited from Base

Base::REST_ENDPOINT

Instance Attribute Summary

Attributes inherited from Generic

#attributes

Attributes inherited from Base

#access_token, #access_token_secret, #consumer_key, #consumer_secret, #rest_endpoint

Instance Method Summary collapse

Methods inherited from Generic

#initialize, #method_missing

Methods inherited from Base

#initialize, #send_request, #sites

Constructor Details

This class inherits a constructor from Muddyit::Generic

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Muddyit::Generic

Instance Method Details

#classificationObject



3
4
5
6
7
8
9
# File 'lib/muddyit/sites/entities/entity.rb', line 3

def classification
  unless @attributes[:type]
    # We merge here as we don't want to overwrite a entity specific confidence score
    @attributes.merge!(self.fetch)
  end
  @attributes[:type]
end

retrieve entities related to the specified entity within the site entities collection

Params

  • options (Optional)



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/muddyit/sites/entities/entity.rb', line 16

def related(options = {})
  api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(URI.encode(@attributes[:uri]))}/related"
  response = @muddyit.send_request(api_url, :get, options)

  results = []
  response.each { |result|
    # The return format needs sorting out here .......
    results.push Muddyit::Sites::Site::Entities::Entity.new(@muddyit, result)
  }
  return results
end