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)


13
14
15
16
17
# File 'lib/factory_trace/structures/trait.rb', line 13

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.



8
9
10
# File 'lib/factory_trace/structures/trait.rb', line 8

def declaration_names
  @declaration_names
end

#definition_pathObject (readonly)

Returns the value of attribute definition_path.



8
9
10
# File 'lib/factory_trace/structures/trait.rb', line 8

def definition_path
  @definition_path
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/factory_trace/structures/trait.rb', line 8

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/factory_trace/structures/trait.rb', line 29

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

  name == other.name && declaration_names == other.declaration_names && definition_path == other.definition_path
end

#to_hHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


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

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