Class: ArchSpec::Component
- Inherits:
-
Object
- Object
- ArchSpec::Component
- Defined in:
- lib/archspec/model.rb
Instance Attribute Summary collapse
-
#constant_reasons ⇒ Object
readonly
Returns the value of attribute constant_reasons.
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
-
#file_reasons ⇒ Object
readonly
Returns the value of attribute file_reasons.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_constant(name, path:, reason: nil) ⇒ Object
- #add_file(path, reason: nil) ⇒ Object
- #includes_constant?(name, path: nil) ⇒ Boolean
-
#initialize(name) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name) ⇒ Component
Returns a new instance of Component.
116 117 118 119 120 121 122 123 |
# File 'lib/archspec/model.rb', line 116 def initialize(name) @name = name.to_sym @files = Set.new @constants = Set.new @constant_occurrences = Set.new @file_reasons = Hash.new { |hash, key| hash[key] = Set.new } @constant_reasons = Hash.new { |hash, key| hash[key] = Set.new } end |
Instance Attribute Details
#constant_reasons ⇒ Object (readonly)
Returns the value of attribute constant_reasons.
114 115 116 |
# File 'lib/archspec/model.rb', line 114 def constant_reasons @constant_reasons end |
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
114 115 116 |
# File 'lib/archspec/model.rb', line 114 def constants @constants end |
#file_reasons ⇒ Object (readonly)
Returns the value of attribute file_reasons.
114 115 116 |
# File 'lib/archspec/model.rb', line 114 def file_reasons @file_reasons end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
114 115 116 |
# File 'lib/archspec/model.rb', line 114 def files @files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
114 115 116 |
# File 'lib/archspec/model.rb', line 114 def name @name end |
Instance Method Details
#add_constant(name, path:, reason: nil) ⇒ Object
130 131 132 133 134 |
# File 'lib/archspec/model.rb', line 130 def add_constant(name, path:, reason: nil) constants.add(name) @constant_occurrences.add([name, path]) constant_reasons[name].add(reason) if reason end |
#add_file(path, reason: nil) ⇒ Object
125 126 127 128 |
# File 'lib/archspec/model.rb', line 125 def add_file(path, reason: nil) files.add(path) file_reasons[path].add(reason) if reason end |
#includes_constant?(name, path: nil) ⇒ Boolean
136 137 138 139 140 |
# File 'lib/archspec/model.rb', line 136 def includes_constant?(name, path: nil) return constants.include?(name) unless path @constant_occurrences.include?([name, path]) end |