Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
More docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich committed Nov 20, 2015
1 parent 0fb092e commit 9220d46
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/binding_dumper/core_ext/local_binding_patch_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
# # => 'do_something'
#
class BindingDumper::CoreExt::LocalBindingPatchBuilder
# Returns +undumped+ object passed to constructor
#
# @return [Hash]
#
attr_reader :undumped

# Takes an undumped object representation
#
# @param undumped [Hash]
#
def initialize(undumped)
Expand Down
8 changes: 8 additions & 0 deletions lib/binding_dumper/core_ext/magic_context_patch_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
module BindingDumper
module CoreExt
class MagicContextPatchBuilder
# Returns +undupmed+ object passed to constructor
#
# @return [Hash]
#
attr_reader :undumped

# Takes an undumped object representation
#
# @param undumped [Hash]
#
def initialize(undumped)
@undumped = undumped
end
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/abstract.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Class with common functionality of all dumpers
#
class BindingDumper::Dumpers::Abstract
# Returns array of object ids that has been already converted
#
# @return [Array<Fixnum>]
#
attr_reader :dumped_ids

# @param abstract_object [Object] any object
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/array_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module BindingDumper
# # => [1,2,3]
#
class Dumpers::ArrayDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Array]
#
alias_method :array, :abstract_object

# Returns true if ArrayDumper can convert +abstract_object+
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/class_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module BindingDumper
# # => MyClass
#
class Dumpers::ClassDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Class]
#
alias_method :klass, :abstract_object

# Returns +true+ if ClassDumper can convert passed +abstract_object+
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/existing_object_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module BindingDumper
# # => true # (they have the same object id)
#
class Dumpers::ExistingObjectDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Hash]
#
alias_method :hash, :abstract_object

# Returns false, this class is only for deconverting
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/hash_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module BindingDumper
# # => { key: 'value' }
#
class Dumpers::HashDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Hash]
#
alias_method :hash, :abstract_object

# Returns true if HashDumper can convert passed +abstract_object+
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/magic_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ module BindingDumper
# # => :config
#
class Dumpers::MagicDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Object]
#
alias_method :object, :abstract_object

# Returns true if MagicDumper can convert passed +abstract_object+
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/object_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module BindingDumper
# # => o
#
class Dumpers::ObjectDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @param [Object]
#
alias_method :object, :abstract_object

# Returns true if ObjectDumper can convert passed +abstract_object+
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/primitive_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module BindingDumper
# @see SUPPORTED_CLASSES
#
class Dumpers::PrimitiveDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Object]
#
alias_method :primitive, :abstract_object

SUPPORTED_CLASSES = [
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/dumpers/proc_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module BindingDumper
# It uses a gem called 'method_source' which may inspect the source of proc/method
#
class Dumpers::ProcDumper < Dumpers::Abstract
# An alias to passed +abstract_object+
#
# @return [Proc]
#
alias_method :_proc, :abstract_object

# Returns true if ProcDumper can convert passed +abstract_object+
Expand Down
27 changes: 27 additions & 0 deletions lib/binding_dumper/load_support/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
# ActiveRecord extension for storing and retrieving dumped bindings
#
# @example
# class StoredBinding < ActiveRecord::Base
# include BindingDumper::LoadSupport::ActiveRecord
#
# def column_with_binding
# :data
# end
# end
#
# StoredBinding.create(data: binding.dump)
#
# StoredBinding.last.debug
#
module BindingDumper::LoadSupport::ActiveRecord
# Returns a column name that stores a dumped binding
#
# @return [#to_s]
#
def column_with_binding
raise NotImplementedError, 'You must define a column that contains binding data'
end

# Loads a binding stored in +column_with_binding+ column
#
# @return [Binding]
#
def stored_binding
require 'rails/backtrace_cleaner'
BindingDumper::UniversalDumper.flush_memories!
data = read_attribute(column_with_binding)
Binding.load(data)
end

# Invokes '.pry' on +stored_binding+
#
# @return nil
#
def debug
stored_binding.pry
end
Expand Down
4 changes: 4 additions & 0 deletions lib/binding_dumper/magic_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
module BindingDumper::MagicObjects
# Builds a tree of objects inside of passed +object+
#
# @param object [Object] object to build a tree from
# @param object_path [#to_s] a string that return a passed object after 'eval'-uation
# @param result [Hash] accumulator for recursion
#
# @return [Hash]
#
def self.magic_tree_from(object, object_path, result = {})
Expand Down

0 comments on commit 9220d46

Please sign in to comment.