Class: Administrate::Field::CSV
- Inherits:
-
Base
- Object
- Base
- Administrate::Field::CSV
- Defined in:
- lib/administrate/field/csv.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
- #blank_sign ⇒ Object
- #has_headers? ⇒ Boolean
- #headers ⇒ Object
- #rewind ⇒ Object
- #to_partial_path(partial = page) ⇒ Object
- #transform ⇒ Object
- #truncate ⇒ Object
Instance Method Details
#blank_sign ⇒ Object
37 38 39 |
# File 'lib/administrate/field/csv.rb', line 37 def blank_sign [:blank_sign] || '-' end |
#has_headers? ⇒ Boolean
29 30 31 |
# File 'lib/administrate/field/csv.rb', line 29 def has_headers? [:headers] == true end |
#headers ⇒ Object
22 23 24 25 26 27 |
# File 'lib/administrate/field/csv.rb', line 22 def headers return [] unless has_headers? rewind @headers ||= transform.first&.headers || [] end |
#rewind ⇒ Object
16 17 18 19 20 |
# File 'lib/administrate/field/csv.rb', line 16 def rewind return nil if data.blank? transform.rewind end |
#to_partial_path(partial = page) ⇒ Object
33 34 35 |
# File 'lib/administrate/field/csv.rb', line 33 def to_partial_path(partial = page) "/fields/csv/#{partial}" end |
#transform ⇒ Object
10 11 12 13 14 |
# File 'lib/administrate/field/csv.rb', line 10 def transform return nil if data.blank? @transform ||= ::CSV.new(data, **csv_args) end |
#truncate ⇒ Object
41 42 43 |
# File 'lib/administrate/field/csv.rb', line 41 def truncate data.to_s.truncate(truncation_length) end |