class Attributor::FieldSelector
Public Class Methods
example(_context = nil, options: {})
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 23 def self.example(_context = nil, options: {}) 3.times.each_with_object([]) do |_i, array| array << Faker::Lordem.words(5) end.join(',') end
json_schema_type()
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 15 def self.json_schema_type :string end
load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **_options)
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 29 def self.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **_options) return nil if value.nil? return value if valid_type? value return {} if value.empty? parsed = Parser.new.parse(value) Transformer.new.apply(parsed) rescue raise CoercionError, context: context, from: value.class, to: self, value: value end
native_type()
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 19 def self.native_type ::Hash end
valid_type?(value)
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 44 def self.valid_type?(value) return true if value.is_a?(native_type) || value.is_a?(self.class) end
validate(_value, _context = nil, _attribute)
click to toggle source
# File lib/attributor/extras/field_selector.rb, line 40 def self.validate(_value, _context = nil, _attribute) [].freeze end