Class: Vapid::Models::Group

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/vapid/models/group.rb

Overview

Group model

Constant Summary collapse

DEFAULT_NAME =
"general".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.named(name) ⇒ Object



15
16
17
# File 'lib/vapid/models/group.rb', line 15

def self.named(name)
  find_by(name: name.downcase) if table_exists?
end

Instance Method Details

#display_nameObject



31
32
33
# File 'lib/vapid/models/group.rb', line 31

def display_name
  (repeating? ? name.pluralize : name).capitalize
end

#fields=(fields) ⇒ Object



23
24
25
# File 'lib/vapid/models/group.rb', line 23

def fields=(fields)
  super fields.each_with_object({}) { |(k, v), h| h[k.downcase] = v }
end

#name=(name) ⇒ Object



19
20
21
# File 'lib/vapid/models/group.rb', line 19

def name=(name)
  super name.try(:downcase)
end

#text_fieldsObject



27
28
29
# File 'lib/vapid/models/group.rb', line 27

def text_fields
  fields.select { |_k, v| v == "text" }.keys
end