Sha256: 7882b4a68e80edaad7706d40e98822429c117b89c184f04b1a1f1927024ab32d

Contents?: true

Size: 426 Bytes

Versions: 5

Compression:

Stored size: 426 Bytes

Contents

module Usable
  def self.Struct(attributes = {})
    Class.new do
      extend Usable

      self.usables = Usable::Config.new(attributes)

      attributes.keys.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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
usable-3.7.1 lib/usable/struct.rb
usable-3.7.0 lib/usable/struct.rb
usable-3.6.2 lib/usable/struct.rb
usable-3.6.1 lib/usable/struct.rb
usable-3.6.0 lib/usable/struct.rb