Class: Rerout::Models::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/models.rb

Overview

Project identity envelope.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, slug:) ⇒ Project

Returns a new instance of Project.



280
281
282
283
284
285
# File 'lib/rerout/models.rb', line 280

def initialize(id:, name:, slug:)
  @id = id
  @name = name
  @slug = slug
  freeze
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



278
279
280
# File 'lib/rerout/models.rb', line 278

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



278
279
280
# File 'lib/rerout/models.rb', line 278

def name
  @name
end

#slugObject (readonly)

Returns the value of attribute slug.



278
279
280
# File 'lib/rerout/models.rb', line 278

def slug
  @slug
end

Class Method Details

.from_hash(hash) ⇒ Object



287
288
289
# File 'lib/rerout/models.rb', line 287

def self.from_hash(hash)
  new(id: hash['id'], name: hash['name'], slug: hash['slug'])
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



295
296
297
# File 'lib/rerout/models.rb', line 295

def ==(other)
  other.is_a?(Project) && other.to_h == to_h
end

#hashObject



300
301
302
# File 'lib/rerout/models.rb', line 300

def hash
  [self.class, id, name, slug].hash
end

#to_hObject



291
292
293
# File 'lib/rerout/models.rb', line 291

def to_h
  { id: id, name: name, slug: slug }
end