Class: Scenic::Cascade::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/scenic/cascade/dependency.rb

Overview

Represents a view dependency

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:) ⇒ Dependency

Returns a new instance of Dependency.

Raises:

  • (TypeError)


11
12
13
14
15
16
17
# File 'lib/scenic/cascade/dependency.rb', line 11

def initialize(from:, to:)
  raise TypeError unless from.is_a?(Scenic::Cascade::View)
  raise TypeError unless to.is_a?(Scenic::Cascade::View)

  @from = from
  @to = to
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



9
10
11
# File 'lib/scenic/cascade/dependency.rb', line 9

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



9
10
11
# File 'lib/scenic/cascade/dependency.rb', line 9

def to
  @to
end

Class Method Details

.from_hash(hash) ⇒ Object



30
31
32
33
34
# File 'lib/scenic/cascade/dependency.rb', line 30

def self.from_hash(hash)
  from = Scenic::Cascade::View.new(name: hash['from'], materialized: hash['from_materialized'])
  to = Scenic::Cascade::View.new(name: hash['to'], materialized: hash['to_materialized'])
  new(from: from, to: to)
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/scenic/cascade/dependency.rb', line 19

def ==(other)
  from == other.from && to == other.to
end

#to_sObject Also known as: inspect

mermaid-like syntax



24
25
26
# File 'lib/scenic/cascade/dependency.rb', line 24

def to_s
  "#{from.name}[#{from}] --> #{to.name}[#{to}]"
end