Class: Destruct
- Inherits:
-
Object
- Object
- Destruct
- Defined in:
- lib/destruct.rb,
lib/destruct/dsl.rb,
lib/destruct/hash.rb,
lib/destruct/object.rb,
lib/destruct/resolver.rb
Defined Under Namespace
Modules: Object Classes: DSL, Hash, Resolver
Constant Summary collapse
- GEMSPEC =
File.("../../destruct.gemspec", __FILE__)
- VERSION =
Gem::Specification.load(GEMSPEC).version.to_s
Instance Method Summary collapse
-
#initialize(object, *paths, &block) ⇒ Destruct
constructor
A new instance of Destruct.
- #to_h ⇒ Object
Constructor Details
#initialize(object, *paths, &block) ⇒ Destruct
Returns a new instance of Destruct.
12 13 14 15 16 |
# File 'lib/destruct.rb', line 12 def initialize(object, *paths, &block) @object = object @paths = paths @block = block || proc { } end |
Instance Method Details
#to_h ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/destruct.rb', line 18 def to_h paths.each_with_object(Hash.new) do |path, hash| resolve(path).each do |key, value| hash[key] = value end end end |