Class: Importo::ImportColumn
- Inherits:
-
Object
- Object
- Importo::ImportColumn
- Defined in:
- lib/importo/import_column.rb
Instance Attribute Summary collapse
- #example ⇒ Object
- #explanation ⇒ Object
- #hint ⇒ Object
- #name ⇒ Object
-
#options ⇒ Object
Returns the value of attribute options.
-
#proc ⇒ Object
Returns the value of attribute proc.
- #value ⇒ Object
Instance Method Summary collapse
- #allowed_names ⇒ Object
- #attribute ⇒ Object
-
#collection ⇒ Object
Collection of values (name, id) that are valid for this field, if a name is entered it will be replaced by the id during pre-processing.
- #delay ⇒ Object
-
#initialize(name: nil, **options, &block) ⇒ ImportColumn
constructor
A new instance of ImportColumn.
-
#overridable? ⇒ Boolean
If set this allows the user to set a value during upload that overrides the uploaded values.
Constructor Details
#initialize(name: nil, **options, &block) ⇒ ImportColumn
Returns a new instance of ImportColumn.
8 9 10 11 12 13 14 |
# File 'lib/importo/import_column.rb', line 8 def initialize(name: nil, **, &block) @name = name @hint = [:hint] @explanation = [:explanation] @options = || {} @proc = block end |
Instance Attribute Details
#example ⇒ Object
47 48 49 |
# File 'lib/importo/import_column.rb', line 47 def example I18n.t(".example.#{[:attribute]}", scope: [:importers, [:scope]], default: "") if [:attribute] end |
#explanation ⇒ Object
39 40 41 |
# File 'lib/importo/import_column.rb', line 39 def explanation I18n.t(".explanation.#{[:attribute]}", scope: [:importers, [:scope]], default: "") if [:attribute] end |
#hint ⇒ Object
35 36 37 |
# File 'lib/importo/import_column.rb', line 35 def hint I18n.t(".hint.#{[:attribute]}", scope: [:importers, [:scope]], default: "") if [:attribute] end |
#name ⇒ Object
20 21 22 23 |
# File 'lib/importo/import_column.rb', line 20 def name name = [:attribute] || @name I18n.t(".column.#{name}", scope: [:importers, [:scope]], default: name) end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/importo/import_column.rb', line 5 def @options end |
#proc ⇒ Object
Returns the value of attribute proc.
5 6 7 |
# File 'lib/importo/import_column.rb', line 5 def proc @proc end |
#value ⇒ Object
43 44 45 |
# File 'lib/importo/import_column.rb', line 43 def value I18n.t(".value.#{[:attribute]}", scope: [:importers, [:scope]], default: "") if [:attribute] end |
Instance Method Details
#allowed_names ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/importo/import_column.rb', line 25 def allowed_names return @allowed_names if @allowed_names.present? name = [:attribute] || @name @allowed_names = I18n.available_locales.map do |locale| I18n.t(".column.#{name}", scope: [:importers, [:scope]], locale: locale, default: name) end.compact.uniq end |
#attribute ⇒ Object
16 17 18 |
# File 'lib/importo/import_column.rb', line 16 def attribute [:attribute] || @name end |
#collection ⇒ Object
Collection of values (name, id) that are valid for this field, if a name is entered it will be replaced by the id during pre-processing
59 60 61 |
# File 'lib/importo/import_column.rb', line 59 def collection [:collection] end |
#delay ⇒ Object
63 64 65 |
# File 'lib/importo/import_column.rb', line 63 def delay [:delay] end |
#overridable? ⇒ Boolean
If set this allows the user to set a value during upload that overrides the uploaded values.
53 54 55 |
# File 'lib/importo/import_column.rb', line 53 def overridable? [:overridable] end |