Class: FactoryTrace::Structures::Trait

Inherits:
Object
  • Object
show all
Includes:
Helpers::Statusable
Defined in:
lib/factory_trace/structures/trait.rb

Constant Summary

Constants included from Helpers::Statusable

Helpers::Statusable::PRIORITY_ORDER

Instance Attribute Summary collapse

Attributes included from Helpers::Statusable

#status

Instance Method Summary collapse

Methods included from Helpers::Statusable

#has_prioritized_status?

Constructor Details

#initialize(name, declaration_names: [], definition_path: nil) ⇒ Trait

Returns a new instance of Trait.

Parameters:

  • name (String)
  • declaration_names (Array<String>) (defaults to: [])
  • definition_path (String) (defaults to: nil)


11
12
13
14
15
# File 'lib/factory_trace/structures/trait.rb', line 11

def initialize(name, declaration_names: [], definition_path: nil)
  @name = name
  @declaration_names = declaration_names
  @definition_path = definition_path
end

Instance Attribute Details

#declaration_namesObject (readonly)

Returns the value of attribute declaration_names.



6
7
8
# File 'lib/factory_trace/structures/trait.rb', line 6

def declaration_names
  @declaration_names
end

#definition_pathObject (readonly)

Returns the value of attribute definition_path.



6
7
8
# File 'lib/factory_trace/structures/trait.rb', line 6

def definition_path
  @definition_path
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/factory_trace/structures/trait.rb', line 6

def name
  @name
end

Instance Method Details

#==(trait) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/factory_trace/structures/trait.rb', line 27

def ==(trait)
  return false unless trait.is_a?(FactoryTrace::Structures::Trait)

  name == trait.name && declaration_names == trait.declaration_names && definition_path == trait.definition_path
end

#to_hHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


18
19
20
21
22
23
24
# File 'lib/factory_trace/structures/trait.rb', line 18

def to_h
  {
    name: name,
    declaration_names: declaration_names,
    definition_path: definition_path
  }
end