Class: Tr8n::Translator
- Inherits:
-
Base
- Object
- Base
- Tr8n::Translator
show all
- Defined in:
- lib/tr8n/translator.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
attributes, belongs_to, has_many, #hash_value, hash_value, #initialize, #method_missing, #to_hash, #update_attributes
Constructor Details
This class inherits a constructor from Tr8n::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Tr8n::Base
Class Method Details
.authorize(application, username, password, options = {}) ⇒ Object
40
41
42
43
|
# File 'lib/tr8n/translator.rb', line 40
def self.authorize(application, username, password, options = {})
data = application.get('oauth/request_token', {:grant_type => :password, :username => username, :password => password})
init(application, data['access_token'])
end
|
.init(application, access_token) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/tr8n/translator.rb', line 45
def self.init(application, access_token)
application.get('translator', {:access_token => access_token}, {:class => Tr8n::Translator, :attributes => {
:application => application,
:access_token => access_token
}})
end
|
Instance Method Details
#applications ⇒ Object
52
53
54
|
# File 'lib/tr8n/translator.rb', line 52
def applications
application.get("translator/applications", {:access_token => access_token}, {:class => Tr8n::Application})
end
|
#feature_enabled?(key) ⇒ Boolean
60
61
62
63
|
# File 'lib/tr8n/translator.rb', line 60
def feature_enabled?(key)
return false unless features
hash_value(features, key)
end
|
#mugshot_url ⇒ Object
65
66
67
68
69
|
# File 'lib/tr8n/translator.rb', line 65
def mugshot_url
return nil unless email
gravatar_id = Digest::MD5.hexdigest(email.downcase)
"http://gravatar.com/avatar/#{gravatar_id}.png?s=48"
end
|
#translations ⇒ Object
56
57
58
|
# File 'lib/tr8n/translator.rb', line 56
def translations
application.get("translator/translations", {:access_token => access_token}, {:class => Tr8n::Application})
end
|