Class: Transifex::ResourceComponents::Content
- Inherits:
-
Object
- Object
- Transifex::ResourceComponents::Content
- Includes:
- CrudRequests::Fetch, CrudRequests::Update
- Defined in:
- lib/transifex/resource_components/content.rb
Instance Attribute Summary collapse
-
#project_slug ⇒ Object
Returns the value of attribute project_slug.
-
#resource_slug ⇒ Object
Returns the value of attribute resource_slug.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_with_file(path_to_file = nil) ⇒ Object
-
#initialize(project_slug, resource_slug) ⇒ Content
constructor
A new instance of Content.
- #update(params = {}, options = {}) ⇒ Object
Methods included from CrudRequests::Update
Methods included from CrudRequests::Fetch
Constructor Details
#initialize(project_slug, resource_slug) ⇒ Content
Returns a new instance of Content.
9 10 11 12 13 14 |
# File 'lib/transifex/resource_components/content.rb', line 9 def initialize(project_slug, resource_slug) raise MissingParametersError.new(["project_slug"]) if project_slug.nil? raise MissingParametersError.new(["resource_slug"]) if resource_slug.nil? @project_slug = project_slug @resource_slug = resource_slug end |
Instance Attribute Details
#project_slug ⇒ Object
Returns the value of attribute project_slug.
7 8 9 |
# File 'lib/transifex/resource_components/content.rb', line 7 def project_slug @project_slug end |
#resource_slug ⇒ Object
Returns the value of attribute resource_slug.
7 8 9 |
# File 'lib/transifex/resource_components/content.rb', line 7 def resource_slug @resource_slug end |
Class Method Details
.authors ⇒ Object
15 16 17 |
# File 'lib/transifex/resource_components/content.rb', line 15 def self. [:project, :resource] end |
Instance Method Details
#fetch_with_file(path_to_file = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/transifex/resource_components/content.rb', line 18 def fetch_with_file(path_to_file = nil) raise MissingParametersError.new(["path_to_file"]) if path_to_file.nil? = {:file => true} file_body = fetch() write_to_file(path_to_file, file_body) end |
#update(params = {}, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/transifex/resource_components/content.rb', line 25 def update(params = {}, = {}) resource_i18n_type = Transifex::Resource.new(@project_slug, @resource_slug).fetch raise Transifex::Error.new("You must use the mimetype #{resource_i18n_type["i18n_type"]} to upload a new resource file") if !check_i18n_type_concordance?(resource_i18n_type["i18n_type"], params[:i18n_type]) super end |