class Typero::HashType
Public Instance Methods
db_schema()
click to toggle source
# File lib/typero/type/types/hash_type.rb, line 24 def db_schema [:jsonb, { null: false, default: '{}' }] end
default()
click to toggle source
# File lib/typero/type/types/hash_type.rb, line 20 def default {} end
set()
click to toggle source
# File lib/typero/type/types/hash_type.rb, line 4 def set if value.is_a?(String) && value[0,1] == '{' @value = JSON.load(value) end @value ||= {} error_for(:not_hash_type_error) unless @value.respond_to?(:keys) && @value.respond_to?(:values) if opts[:allow] for key in @value.keys @value.delete(key) unless opts[:allow].include?(key) end end end