Sha256: 38d6b898e873564f6c6249dfad7dc47a2f2e301df292d45c81459158aa6ff6a1

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
module SmartCore::ValueObject::Interface::Serializable
  class << self
    # @param base_klass [Class<SmartCore::ValueObject>]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def included(base_klass)
      base_klass.include(AsHash)
    end
  end

  # @api private
  # @since 0.1.0
  module AsHash
    # @return [Hash<Symbol,Any>]
    #
    # @note strongly dependes on SmartCore::Initializer implementation
    #
    # @api public
    # @since 0.1.0
    def to_h
      __collect_params__.merge(__collect_options__)
    end
    alias_method :to_hash, :to_h
    alias_method :as_hash, :to_h
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smart_value-object-0.2.0 lib/smart_core/value_object/interface/serializable.rb
smart_value-object-0.1.0 lib/smart_core/value_object/interface/serializable.rb