Class: WebTranslateIt::TermTranslation
- Inherits:
-
Object
- Object
- WebTranslateIt::TermTranslation
- Defined in:
- lib/web_translate_it/term_translation.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#new_record ⇒ Object
Returns the value of attribute new_record.
-
#status ⇒ Object
Returns the value of attribute status.
-
#term_id ⇒ Object
Returns the value of attribute term_id.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ TermTranslation
constructor
Initialize a new WebTranslateIt::TermTranslation.
-
#save ⇒ Object
Update or Create a WebTranslateIt::TermTranslation.
- #to_hash ⇒ Object
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ TermTranslation
Initialize a new WebTranslateIt::TermTranslation
Implementation Example:
WebTranslateIt::TermTranslation.new({ :text => "Super!" })
to instantiate a new TermTranslation.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/web_translate_it/term_translation.rb', line 18 def initialize(params = {}) params.stringify_keys! self.id = params['id'] || nil self.locale = params['locale'] || nil self.text = params['text'] || nil self.description = params['description'] || nil self.status = params['status'] || nil self.term_id = params['term_id'] || nil self.new_record = true end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def id @id end |
#locale ⇒ Object
Returns the value of attribute locale.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def locale @locale end |
#new_record ⇒ Object
Returns the value of attribute new_record.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def new_record @new_record end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def status @status end |
#term_id ⇒ Object
Returns the value of attribute term_id.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def term_id @term_id end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/web_translate_it/term_translation.rb', line 7 def text @text end |
Instance Method Details
#save ⇒ Object
Update or Create a WebTranslateIt::TermTranslation
Implementation Example:
translation = WebTranslateIt::TermTranslation.new({ :term_id => "1234", :text => "Super!" })
WebTranslateIt::Connection.new('secret_api_token') do
translation.save
end
39 40 41 |
# File 'lib/web_translate_it/term_translation.rb', line 39 def save new_record ? create : update end |
#to_hash ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/web_translate_it/term_translation.rb', line 43 def to_hash { 'id' => id, 'locale' => locale, 'text' => text, 'description' => description, 'status' => status } end |
#to_json(*_args) ⇒ Object
53 54 55 |
# File 'lib/web_translate_it/term_translation.rb', line 53 def to_json(*_args) MultiJson.dump(to_hash) end |