Class: FactoryTrace::Structures::Trait

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, owner_name) ⇒ Trait

Returns a new instance of Trait.

Parameters:

  • name (String)
  • owner_name (String, nil)


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

def initialize(name, owner_name)
  @name = name
  @owner_name = owner_name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/factory_trace/structures/trait.rb', line 4

def name
  @name
end

#owner_nameObject (readonly)

Returns the value of attribute owner_name.



4
5
6
# File 'lib/factory_trace/structures/trait.rb', line 4

def owner_name
  @owner_name
end

Instance Method Details

#==(trait) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  name == trait.name && owner_name == trait.owner_name
end

#to_hHash<Symbol, String>

Returns:

  • (Hash<Symbol, String>)


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

def to_h
  {
    name: name,
    owner_name: owner_name
  }
end