Class: FactoryTrace::Structures::Factory
- Inherits:
-
Object
- Object
- FactoryTrace::Structures::Factory
- Includes:
- Helpers::Statusable
- Defined in:
- lib/factory_trace/structures/factory.rb
Constant Summary
Constants included from Helpers::Statusable
Helpers::Statusable::PRIORITY_ORDER
Instance Attribute Summary collapse
-
#declaration_names ⇒ Object
readonly
Returns the value of attribute declaration_names.
-
#definition_path ⇒ Object
readonly
Returns the value of attribute definition_path.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#parent_name ⇒ Object
readonly
Returns the value of attribute parent_name.
-
#traits ⇒ Object
readonly
Returns the value of attribute traits.
Attributes included from Helpers::Statusable
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(names, traits, parent_name: nil, declaration_names: [], definition_path: nil) ⇒ Factory
constructor
A new instance of Factory.
-
#merge!(factory) ⇒ Object
Merge passed factory into self.
- #to_h ⇒ Hash<Symbol, Object>
Methods included from Helpers::Statusable
Constructor Details
#initialize(names, traits, parent_name: nil, declaration_names: [], definition_path: nil) ⇒ Factory
Returns a new instance of Factory.
15 16 17 18 19 20 21 |
# File 'lib/factory_trace/structures/factory.rb', line 15 def initialize(names, traits, parent_name: nil, declaration_names: [], definition_path: nil) @names = names @traits = traits @parent_name = parent_name @declaration_names = declaration_names @definition_path = definition_path end |
Instance Attribute Details
#declaration_names ⇒ Object (readonly)
Returns the value of attribute declaration_names.
8 9 10 |
# File 'lib/factory_trace/structures/factory.rb', line 8 def declaration_names @declaration_names end |
#definition_path ⇒ Object (readonly)
Returns the value of attribute definition_path.
8 9 10 |
# File 'lib/factory_trace/structures/factory.rb', line 8 def definition_path @definition_path end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
8 9 10 |
# File 'lib/factory_trace/structures/factory.rb', line 8 def names @names end |
#parent_name ⇒ Object (readonly)
Returns the value of attribute parent_name.
8 9 10 |
# File 'lib/factory_trace/structures/factory.rb', line 8 def parent_name @parent_name end |
#traits ⇒ Object (readonly)
Returns the value of attribute traits.
8 9 10 |
# File 'lib/factory_trace/structures/factory.rb', line 8 def traits @traits end |
Instance Method Details
#==(other) ⇒ Boolean
44 45 46 47 48 49 50 51 52 |
# File 'lib/factory_trace/structures/factory.rb', line 44 def ==(other) return false unless other.is_a?(FactoryTrace::Structures::Factory) names == other.names && traits == other.traits && parent_name == other.parent_name && declaration_names == other.declaration_names && definition_path == other.definition_path end |
#merge!(factory) ⇒ Object
Merge passed factory into self
37 38 39 40 41 |
# File 'lib/factory_trace/structures/factory.rb', line 37 def merge!(factory) factory.traits.each do |trait| traits << trait unless traits.any? { |t| t.name == trait.name } end end |
#to_h ⇒ Hash<Symbol, Object>
24 25 26 27 28 29 30 31 32 |
# File 'lib/factory_trace/structures/factory.rb', line 24 def to_h { names: names, traits: traits.map(&:to_h), parent_name: parent_name, declaration_names: declaration_names, definition_path: definition_path } end |