Class: Moodwall::Mood

Inherits:
Record
  • Object
show all
Defined in:
lib/moodwall/mood.rb

Instance Attribute Summary collapse

Attributes inherited from Record

#id, #repository

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#==, all, #delete, find!, #new_record?, next_id, #reload, repository, reset, #save, transaction

Constructor Details

#initialize(name:, current: false) ⇒ Mood

Returns a new instance of Mood.



6
7
8
9
# File 'lib/moodwall/mood.rb', line 6

def initialize(name:, current: false)
  @name    = name
  @current = current
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



4
5
6
# File 'lib/moodwall/mood.rb', line 4

def current
  @current
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/moodwall/mood.rb', line 3

def name
  @name
end

Class Method Details

.choose_current(name:) ⇒ Object



16
17
18
19
# File 'lib/moodwall/mood.rb', line 16

def choose_current(name:)
  nullify_current
  choose_new_current(name)
end

.currentObject



12
13
14
# File 'lib/moodwall/mood.rb', line 12

def current
  all.find { |m| m.current == true }
end

.find_by_name(name) ⇒ Object



21
22
23
# File 'lib/moodwall/mood.rb', line 21

def find_by_name(name)
  all.find { |m| m.name.casecmp(name).zero? }
end

.list_namesObject



25
26
27
# File 'lib/moodwall/mood.rb', line 25

def list_names
  all.map(&:name)
end