Sha256: bd7947c897034354d4fcf6c553a85b3ef50036145549ee1fc98ac48b801e098f
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require "active_support" require "active_support/core_ext" require "schema_serializer/definition" require "schema_serializer/schema" require "schema_serializer/serializable" require "schema_serializer/errors" require "schema_serializer/version" require "schema_serializer/railtie" if defined?(Rails) class SchemaSerializer attr_reader :object class << self attr_reader :definition def load_definition(path) self.definition = YamlExt.load(path) end def definition=(define) @definition = define.is_a?(SchemaSerializer::Definition) ? define : SchemaSerializer::Definition.new(define) end end def initialize(object, _options = {}) @object = object end def as_json(_options = nil) schema.serialize(self) end def schema ::SchemaSerializer.definition.schema(schema_name) end def schema_name return self.class.name.sub("Serializer", "") if self.class < SchemaSerializer object.class.name end private def method_missing(name, *args, &block) super unless object.respond_to?(name) object.public_send(name, *args, &block) end def respond_to_missing?(name, _include_private = false) object.respond_to?(name) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schema_serializer-0.1.0 | lib/schema_serializer.rb |