Class: Dread::Graph
- Inherits:
-
Object
- Object
- Dread::Graph
- Defined in:
- lib/dread/graph.rb
Constant Summary collapse
- INDENT_INCREASE =
2
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#pluralized ⇒ Object
readonly
Returns the value of attribute pluralized.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(clazz, indent = 0, pluralized = false) ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize(clazz, indent = 0, pluralized = false) ⇒ Graph
Returns a new instance of Graph.
10 11 12 13 14 |
# File 'lib/dread/graph.rb', line 10 def initialize(clazz, indent=0, pluralized=false) set_and_verify_clazz(clazz) @indent = indent @pluralized = pluralized end |
Instance Attribute Details
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
8 9 10 |
# File 'lib/dread/graph.rb', line 8 def clazz @clazz end |
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
8 9 10 |
# File 'lib/dread/graph.rb', line 8 def indent @indent end |
#pluralized ⇒ Object (readonly)
Returns the value of attribute pluralized.
8 9 10 |
# File 'lib/dread/graph.rb', line 8 def pluralized @pluralized end |
Instance Method Details
#draw ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dread/graph.rb', line 16 def draw puts " " * indent + clazz_name() @clazz.reflections.each do |assoc_name, assoc_data| if assoc_data.[:dependent] == :delete puts " "*(indent+INDENT_INCREASE) + "#{assoc_name} [#{assoc_data.table_name.classify}]" elsif assoc_data.[:dependent] == :destroy Graph.new(assoc_data.table_name, indent + INDENT_INCREASE, pluralized = true).draw end end end |