Sha256: 236b7dcf1601f72026e7484b63d2f3dde6ee40b51e4858e6af92d71b531b1b9d
Contents?: true
Size: 640 Bytes
Versions: 1
Compression:
Stored size: 640 Bytes
Contents
module Usable def self.Struct(attributes = {}) Class.new do extend Usable self.usables = Usable::Config.new(attributes) define_usable_accessors attributes.keys.map(&:to_sym).each do |key| define_method(key) { @attrs[key] } define_method("#{key}=") { |new_val| @attrs[key] = new_val } end attr_accessor :attrs def initialize(attrs = {}) @attrs = usables.merge(attrs) end def [](key) @attrs[key] end def []=(key, val) @attrs[key] = val end def each(&block) @attrs.each(&block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
usable-3.8.0 | lib/usable/struct.rb |