Sha256: 0f4905fe4fe94a31c7045baa5ec45b3cb49a817e980b92a64a2f2eb9b68a1ef6

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

class BasicSerializer
  module DSL
    def attributes
      @attributes ||= {}
    end

    def attribute(name, type = nil)
      attributes[name] = type || :default

      return if method_defined?(name)

      define_method(name) { object.send(name) }
    end

    def model_name(name)
      @model_name ||= name
    end

    def custom_model_name
      @model_name || name.gsub("Serializer", "")
    end

    def schema_ref(ref)
      @schema_ref ||= ref
    end

    def format(name, pretty: false)
      @format ||= { name: name, pretty: pretty }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basic_serializer-0.1.7 lib/basic_serializer/dsl.rb