Sha256: cfa2905df0f1bd4148625b5c5d6c429b44b55c95c8012e73737bccbd17c10b6d

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

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

    def attribute(name, type)
      attributes[name] = type

      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

2 entries across 2 versions & 1 rubygems

Version Path
basic_serializer-0.1.6 lib/basic_serializer/dsl.rb
basic_serializer-0.1.5 lib/basic_serializer/dsl.rb