Sha256: 40596ae5ebf3d05586a9a84c22ef423a48d7c9dd04f6f0a7515bec1ec7b0e81b
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 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 def definition @definition end def definition=(define) define = SchemaSerializer::Definition.new(define) unless define.is_a?(SchemaSerializer::Definition) @definition = define end end def initialize(object, options = {}) @object = object end def as_json(options = nil) schema.serialize(self) end def schema self.class.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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
schema_serializer-0.0.6 | lib/schema_serializer.rb |
schema_serializer-0.0.5 | lib/schema_serializer.rb |
schema_serializer-0.0.4 | lib/schema_serializer.rb |