Class: RubyLokaliseApi::Resources::Base
- Inherits:
-
Object
- Object
- RubyLokaliseApi::Resources::Base
- Extended by:
- Concerns::AttrsLoadable, Concerns::Unsupportable, Utils::Attributes
- Includes:
- Concerns::HashAccessible, Utils::Keys
- Defined in:
- lib/ruby_lokalise_api/resources/base.rb
Direct Known Subclasses
Branch, Comment, Contributor, CustomTranslationStatus, File, Jwt, Key, OAuth2RefreshedToken, OAuth2Token, Order, PaymentCard, PermissionTemplate, Project, ProjectLanguage, QueuedProcess, Screenshot, Segment, Snapshot, SystemLanguage, Task, Team, TeamUser, TeamUserBillingDetails, TeamUserGroup, Translation, TranslationProvider, Webhook
Constant Summary collapse
- ATTRS_FILENAME =
'resource_attributes.yml'
Class Method Summary collapse
-
.delegate_call(from, to = nil) ⇒ Object
Delegates instance method calls to the client methods.
Instance Method Summary collapse
-
#destroy ⇒ Object
Deletes the current resource.
-
#initialize(response) ⇒ Base
constructor
A new instance of Base.
-
#reload_data ⇒ Object
Reloads the current resource with new values from the API.
-
#update(params) ⇒ Object
Updates the current resource.
Methods included from Concerns::Unsupportable
Methods included from Concerns::AttrsLoadable
Methods included from Utils::Keys
#collection_key_for, #data_key_for
Methods included from Concerns::HashAccessible
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 |
# File 'lib/ruby_lokalise_api/resources/base.rb', line 16 def initialize(response) @self_endpoint = response.endpoint populate_attrs_from response.content end |
Class Method Details
.delegate_call(from, to = nil) ⇒ Object
Delegates instance method calls to the client methods
41 42 43 44 45 |
# File 'lib/ruby_lokalise_api/resources/base.rb', line 41 def delegate_call(from, to = nil) define_method(from) do |*args| @self_endpoint.client.send((to || from), *read_main_params.push(*args)) end end |
Instance Method Details
#destroy ⇒ Object
Deletes the current resource
28 29 30 31 32 |
# File 'lib/ruby_lokalise_api/resources/base.rb', line 28 def destroy RubyLokaliseApi::Generics::DeletedResource.new( reinit_endpoint.do_delete.content ) end |
#reload_data ⇒ Object
Reloads the current resource with new values from the API
35 36 37 |
# File 'lib/ruby_lokalise_api/resources/base.rb', line 35 def reload_data self.class.new reinit_endpoint.do_get end |
#update(params) ⇒ Object
Updates the current resource
23 24 25 |
# File 'lib/ruby_lokalise_api/resources/base.rb', line 23 def update(params) self.class.new reinit_endpoint(params).do_put end |