Sha256: fb8215cf55051efb4ef0d28e246dc2524e4d34119fb31aafffe060a5a8d52ef2
Contents?: true
Size: 1.05 KB
Versions: 7
Compression:
Stored size: 1.05 KB
Contents
module ActiveData class Config include Singleton attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class, :base_concern, :_normalizers, :_typecasters def self.delegated public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods end def initialize @include_root_in_json = false @i18n_scope = :active_data @logger = Logger.new(STDERR) @primary_attribute = :id @_normalizers = {} @_typecasters = {} end def normalizer(name, &block) if block _normalizers[name.to_sym] = block else _normalizers[name.to_sym] or raise NormalizerMissing, name end end def typecaster(*classes, &block) classes = classes.flatten if block _typecasters[classes.first.to_s.camelize] = block else _typecasters[classes.detect do |klass| _typecasters[klass.to_s.camelize] end.to_s.camelize] or raise TypecasterMissing, classes end end end end
Version data entries
7 entries across 7 versions & 1 rubygems