Sha256: 693b8d86681745c576b4ce399e79ee43e638d337aa1ce0368f63ce4c316089b2

Contents?: true

Size: 465 Bytes

Versions: 7

Compression:

Stored size: 465 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
          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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
u-attributes-1.2.0 lib/micro/attributes/features/initialize.rb
u-attributes-1.1.1 lib/micro/attributes/features/initialize.rb
u-attributes-1.1.0 lib/micro/attributes/features/initialize.rb
u-attributes-1.0.1 lib/micro/attributes/features/initialize.rb
u-attributes-1.0.0 lib/micro/attributes/features/initialize.rb
u-attributes-0.14.0 lib/micro/attributes/features/initialize.rb
u-attributes-0.13.0 lib/micro/attributes/features/initialize.rb