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
- #==(factory) ⇒ 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.
13 14 15 16 17 18 19 |
# File 'lib/factory_trace/structures/factory.rb', line 13 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.
6 7 8 |
# File 'lib/factory_trace/structures/factory.rb', line 6 def declaration_names @declaration_names end |
#definition_path ⇒ Object (readonly)
Returns the value of attribute definition_path.
6 7 8 |
# File 'lib/factory_trace/structures/factory.rb', line 6 def definition_path @definition_path end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
6 7 8 |
# File 'lib/factory_trace/structures/factory.rb', line 6 def names @names end |
#parent_name ⇒ Object (readonly)
Returns the value of attribute parent_name.
6 7 8 |
# File 'lib/factory_trace/structures/factory.rb', line 6 def parent_name @parent_name end |
#traits ⇒ Object (readonly)
Returns the value of attribute traits.
6 7 8 |
# File 'lib/factory_trace/structures/factory.rb', line 6 def traits @traits end |
Instance Method Details
#==(factory) ⇒ Boolean
42 43 44 45 46 47 48 49 50 |
# File 'lib/factory_trace/structures/factory.rb', line 42 def ==(factory) return false unless factory.is_a?(FactoryTrace::Structures::Factory) names == factory.names && traits == factory.traits && parent_name == factory.parent_name && declaration_names == factory.declaration_names && definition_path == factory.definition_path end |
#merge!(factory) ⇒ Object
Merge passed factory into self
35 36 37 38 39 |
# File 'lib/factory_trace/structures/factory.rb', line 35 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>
22 23 24 25 26 27 28 29 30 |
# File 'lib/factory_trace/structures/factory.rb', line 22 def to_h { names: names, traits: traits.map(&:to_h), parent_name: parent_name, declaration_names: declaration_names, definition_path: definition_path } end |