class Attributor::CSV
Public Class Methods
decode_string(value, _context)
click to toggle source
# File lib/attributor/types/csv.rb, line 3 def self.decode_string(value, _context) value.split(',') end
describe(shallow = false, example: nil)
click to toggle source
Calls superclass method
Attributor::Collection::describe
# File lib/attributor/types/csv.rb, line 30 def self.describe(shallow = false, example: nil) hash = super(shallow) hash.delete(:member_attribute) hash[:example] = example if example hash end
dump(values, **opts)
click to toggle source
# File lib/attributor/types/csv.rb, line 7 def self.dump(values, **opts) case values when ::String values when ::Array values.collect { |value| member_attribute.dump(value, **opts).to_s }.join(',') when nil nil else context = opts[:context] || DEFAULT_ROOT_CONTEXT name = context.last.to_s type = values.class.name reason = 'Attributor::CSV only supports dumping values of type ' \ "Array or String, not #{values.class.name}." raise DumpError, context: context, name: name, type: type, original_exception: reason end end
example(context = nil, options: {})
click to toggle source
Calls superclass method
Attributor::Collection::example
# File lib/attributor/types/csv.rb, line 25 def self.example(context = nil, options: {}) collection = super(context, options: options.merge(size: (2..4))) collection.join(',') end
family()
click to toggle source
# File lib/attributor/types/csv.rb, line 37 def self.family Collection.family end
json_schema_type()
click to toggle source
# File lib/attributor/types/csv.rb, line 41 def self.json_schema_type :string end