module NoSE::Debug

Various helpful debugging snippets

Public Class Methods

break_on_indexes(*index_keys) click to toggle source

Convenience method to break in IndexLookupStep when a particular set of indexes is reach when planning @return [void]

# File lib/nose/debug.rb, line 17
def self.break_on_indexes(*index_keys)
  apply = binding.of_caller(1)
  parent = apply.eval 'parent'
  index = apply.eval 'index'
  current_keys = parent.parent_steps.indexes.map(&:key) << index.key

  # rubocop:disable Lint/Debugger
  binding.pry if current_keys == index_keys
  # rubocop:enable Lint/Debugger
end
export_model(model) click to toggle source

Export entities in a model as global variales for easier access when debugging @return [void]

# File lib/nose/debug.rb, line 31
def self.export_model(model)
  model.entities.each do |name, entity|
    # rubocop:disable Lint/Eval
    eval("$#{name} = entity")
    # rubocop:enable Lint/Eval

    entity.fields.merge(entity.foreign_keys).each do |field_name, field|
      entity.define_singleton_method field_name.to_sym, -> { field }
    end
  end

  nil
end