Class: LokaliseManager::TaskDefinitions::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/lokalise_manager/task_definitions/base.rb

Overview

Base class for LokaliseManager task definitions, providing common methods and logic for importer and exporter classes. Handles API client interactions and configuration merging.

Direct Known Subclasses

Exporter, Importer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_opts = {}, global_config = LokaliseManager::GlobalConfig) ⇒ Base

Initializes a new task object by merging custom and global configurations.

Parameters:

  • custom_opts (Hash) (defaults to: {})

    Custom configurations for specific tasks.

  • global_config (Object) (defaults to: LokaliseManager::GlobalConfig)

    Reference to the global configuration.



19
20
21
22
# File 'lib/lokalise_manager/task_definitions/base.rb', line 19

def initialize(custom_opts = {}, global_config = LokaliseManager::GlobalConfig)
  merged_opts = merge_configs(global_config, custom_opts)
  @config = build_config_class(merged_opts)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



13
14
15
# File 'lib/lokalise_manager/task_definitions/base.rb', line 13

def config
  @config
end

Instance Method Details

#api_clientRubyLokaliseApi::Client

Retrieves or creates a Lokalise API client based on configuration.

Returns:

  • (RubyLokaliseApi::Client)

    Lokalise API client.



27
28
29
# File 'lib/lokalise_manager/task_definitions/base.rb', line 27

def api_client
  @api_client ||= create_api_client
end

#reset_api_client!Object

Resets API client



32
33
34
35
36
# File 'lib/lokalise_manager/task_definitions/base.rb', line 32

def reset_api_client!
  ::RubyLokaliseApi.reset_client!
  ::RubyLokaliseApi.reset_oauth2_client!
  @api_client = nil
end