Sha256: 70dbdea5d56b2b72f1936b67b9fa0a5f38836f77e9a5a25a9de3b38fe13950da

Contents?: true

Size: 845 Bytes

Versions: 8

Compression:

Stored size: 845 Bytes

Contents

module Sentimeta::Client::Data
  extend self
  extend Sentimeta::RestClient

  def sphere() Sentimeta.sphere end

  
  %i(criteria spheres objects catalog).each do |endpoint|
    define_method endpoint do |options={}|
      get(endpoint, options)[endpoint.to_s]
    end
  end

  def attributes options={}
    get(:attributes, options)['values']
  end

  def medal id, options
    response = get(:objects, options.merge(id: "#{ id }/medal"))
    if response.ok? && response.body['medal'].present? && response.body['object'].present?
      response.body = response.body.slice 'medal', 'object'
      response
    end
  end

  ##
  # Usage:
  #   search text: 'pitt' [, where: 'actors' ]
  def search options={}
    result = get :search, options
    if options.has_key? :where
      result[options[:where]]
    else
      result
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sentimeta-0.1.22 lib/sentimeta/client/data.rb
sentimeta-0.1.21 lib/sentimeta/client/data.rb
sentimeta-0.1.20 lib/sentimeta/client/data.rb
sentimeta-0.1.10 lib/sentimeta/client/data.rb
sentimeta-0.1.9 lib/sentimeta/client/data.rb
sentimeta-0.1.8 lib/sentimeta/client/data.rb
sentimeta-0.1.7 lib/sentimeta/client/data.rb
sentimeta-0.1.6 lib/sentimeta/client/data.rb