Sha256: af9cc1af9cfa2b90b7865f91be103fff0cce943dff32895873b23aaa9b7accc6
Contents?: true
Size: 422 Bytes
Versions: 1
Compression:
Stored size: 422 Bytes
Contents
# frozen_string_literal: true require_relative 'chainable_accessor/version' module ChainableAccessor def chainable_accessor(*attributes, immutable: false) mod = Module.new do attributes.each do |name| define_method name do |val = nil| return super() unless val (immutable ? dup : self).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.2.0 | lib/chainable_accessor.rb |