Sha256: 4dcdceefea403ec0b837b96d95b62a309ebce754f1e8829fa87774d08d22e60d
Contents?: true
Size: 614 Bytes
Versions: 3
Compression:
Stored size: 614 Bytes
Contents
require 'dry-types' require 'dry/struct/version' require 'dry/struct/errors' require 'dry/struct/class_interface' require 'dry/struct/hashify' require 'dry/struct/value' module Dry class Struct extend ClassInterface constructor_type(:permissive) def initialize(attributes) attributes.each { |key, value| instance_variable_set("@#{key}", value) } end def [](name) public_send(name) end def to_hash self.class.schema.keys.each_with_object({}) do |key, result| result[key] = Hashify[self[key]] end end alias_method :to_h, :to_hash end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-struct-0.2.0 | lib/dry/struct.rb |
dry-struct-0.1.1 | lib/dry/struct.rb |
dry-struct-0.1.0 | lib/dry/struct.rb |