Sha256: b7ba7183cd523a5e3191e142ae1217ffb0125e6f97078040064c3432234c5691
Contents?: true
Size: 568 Bytes
Versions: 24
Compression:
Stored size: 568 Bytes
Contents
# A struct that only allows keyword arguments. # For example, this should be used to create value objects that are returned from service methods, # instead of just returning a hash. # # Usage: # class Foo < Percy::KeywordStruct.new(:bar, :baz, :qux) # end # # foo = Foo.new(bar: 123, baz: true) # foo.bar # --> 123 # foo.baz # --> true # foo.qux # --> nil # foo.fake # --> raises NoMethodError module Percy class KeywordStruct < Struct def initialize(**kwargs) super(kwargs.keys) kwargs.each { |k, v| self[k] = v } end end end
Version data entries
24 entries across 24 versions & 1 rubygems