Sha256: 7bedf09048dfd2928d4ba16fbdd1a6c74d8ea08aae170b0033acf532f2aa345e

Contents?: true

Size: 379 Bytes

Versions: 1

Compression:

Stored size: 379 Bytes

Contents

# frozen_string_literal: true

require_relative 'chainable_accessor/version'

module ChainableAccessor
  def chainable_accessor(*attributes)
    mod = Module.new do
      attributes.each do |name|
        define_method name do |val = nil|
          return super() unless val

          tap { |x| x.send("#{name}=", val) }
        end
      end
    end
    prepend(mod)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chainable_accessor-0.1.0 lib/chainable_accessor.rb