Sha256: 5ddc6c6fd038444d1da60cd267e23b52424075535e831e6d6076a2eb259ecabd

Contents?: true

Size: 568 Bytes

Versions: 7

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

module Micro::Attributes
  module Features
    module Initialize
      def self.included(base)
        base.class_eval(<<-RUBY)
          def initialize(arg)
            self.attributes = arg
            __call_after_micro_attribute
          end
        RUBY
      end

      def with_attribute(key, val)
        self.class.new(attributes.merge(key => val))
      end

      def with_attributes(arg)
        self.class.new(attributes.merge(arg))
      end

      private

        def __call_after_micro_attribute; end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
u-attributes-2.4.0 lib/micro/attributes/features/initialize.rb
u-attributes-2.3.0 lib/micro/attributes/features/initialize.rb
u-attributes-2.2.0 lib/micro/attributes/features/initialize.rb
u-attributes-2.1.1 lib/micro/attributes/features/initialize.rb
u-attributes-2.1.0 lib/micro/attributes/features/initialize.rb
u-attributes-2.0.1 lib/micro/attributes/features/initialize.rb
u-attributes-2.0.0 lib/micro/attributes/features/initialize.rb