Module: MiniGauge

Defined in:
lib/mini_gauge.rb

Overview

doc = Organization.find(400).to_dot_notation(:include =>

:memberships => [
  {:invoice_item => :invoice, 
  => [
      :product, 
      {:invoice_item => :invoice
    ]
  }
]

})

File.open(“big_org.dot”, ‘w’) {|f| f.write(doc) }

to_dot_notation also accepts a block and passes the graph object to it, in case there are extra details to add. For example, to only do some of the member products try this:

@org_membership = Membership::Organizational::Base.find(400)
doc = @org_membership.to_dot_notation(:include => => :people) do |graph|
  @org_membership.member_products.contact_reps.each do |cr_mpr|
    graph.add(:source => @org_membership, :destination => cr_mpr, :label => "member_products.contact_reps")
    cr_mpr.fill_dot_graph(graph, :include => [=> :member, => :invoice])
  end
end

Classes can also be exported to dot notation, where the attributes and active record relations will be displayed

They work the same way, at the class level:

doc = Membership::Organizational::Base.to_dot_notation

By default only one level of relations is fetched, but if more are desired to_dot_notation will also accept a block:

doc = Membership::Organizational::Base.to_dot_notation do |graph|
  Invoice.fill_with_relations(graph)
end

Defined Under Namespace

Modules: ClassMethods, InstanceMethods Classes: Graph

Constant Summary collapse

HIDDEN_FIELDS =
[ "created_at", "created_on", "updated_at", "updated_on",
"lock_version", "type", "id", "position", "parent_id", "lft", 
"rgt", "quote", "template", "salt", "persistence_token", "crypted_password", "current_login_at"]

Class Method Summary collapse

Class Method Details

.enable!Object

Include this module in AR Base



76
77
78
# File 'lib/mini_gauge.rb', line 76

def self.enable!
  ActiveRecord::Base.send(:include, MiniGauge)
end

.included(base) ⇒ Object



80
81
82
83
# File 'lib/mini_gauge.rb', line 80

def self.included(base)
  base.send :include, InstanceMethods
  base.extend ClassMethods
end