Class: Lit::Import
- Inherits:
-
Object
- Object
- Lit::Import
- Defined in:
- lib/lit/import.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#locale_keys ⇒ Object
readonly
Returns the value of attribute locale_keys.
-
#skip_nil ⇒ Object
readonly
Returns the value of attribute skip_nil.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false) ⇒ Import
constructor
A new instance of Import.
- #perform ⇒ Object
Constructor Details
#initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false) ⇒ Import
Returns a new instance of Import.
13 14 15 16 17 18 19 20 21 |
# File 'lib/lit/import.rb', line 13 def initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false) raise ArgumentError, 'format must be yaml or csv' if %i[yaml csv].exclude?(format.to_sym) @input = input @locale_keys = locale_keys.presence || I18n.available_locales @format = format @skip_nil = skip_nil @dry_run = dry_run @raw = raw end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
11 12 13 |
# File 'lib/lit/import.rb', line 11 def format @format end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
11 12 13 |
# File 'lib/lit/import.rb', line 11 def input @input end |
#locale_keys ⇒ Object (readonly)
Returns the value of attribute locale_keys.
11 12 13 |
# File 'lib/lit/import.rb', line 11 def locale_keys @locale_keys end |
#skip_nil ⇒ Object (readonly)
Returns the value of attribute skip_nil.
11 12 13 |
# File 'lib/lit/import.rb', line 11 def skip_nil @skip_nil end |
Class Method Details
.call(**kwargs) ⇒ Object
6 7 8 |
# File 'lib/lit/import.rb', line 6 def call(**kwargs) new(**kwargs).perform end |
Instance Method Details
#perform ⇒ Object
23 24 25 |
# File 'lib/lit/import.rb', line 23 def perform send(:"import_#{format}") end |