lib/rom/struct.rb in rom-repository-0.3.1 vs lib/rom/struct.rb in rom-repository-1.0.0.beta1
- old
+ new
@@ -1,37 +1,28 @@
+require 'dry/struct'
+
module ROM
# Simple data-struct
#
# By default mappers use this as the model
#
# @api public
- class Struct
- # Coerces a struct to a hash
+ class Struct < Dry::Struct
+ # Returns a short string representation
#
- # @return [Hash]
+ # @return [String]
#
- # @api private
- def to_hash
- to_h
- end
-
- # Reads an attribute value
- #
- # @param name [Symbol] The name of the attribute
- #
- # @return [Object]
- #
# @api public
- def [](name)
- __send__(name)
+ def to_s
+ "#<#{self.class}:0x#{(object_id << 1).to_s(16)}>"
end
- # Returns a short string representation
+ # Return attribute value
#
- # @return [String]
+ # @param [Symbol] name The attribute name
#
# @api public
- def to_s
- "#<#{self.class}:0x#{(object_id << 1).to_s(16)}>"
+ def fetch(name)
+ __send__(name)
end
end
end