Class: MessageFunction
- Inherits:
-
Object
- Object
- MessageFunction
- Defined in:
- app/models/message_function.rb
Constant Summary collapse
- @@functions =
[ MessageFunction.new('welcome', 'Welcome'), MessageFunction.new('invitation', 'Invitation' ), MessageFunction.new('group_welcome', 'Group welcome'), MessageFunction.new('group_invitation', 'Group invitation' ), MessageFunction.new('password_reset', 'Password instructions'), MessageFunction.new('activation', 'Activation instructions') ]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #humanize ⇒ Object
-
#initialize(name, description = '') ⇒ MessageFunction
constructor
A new instance of MessageFunction.
- #symbol ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, description = '') ⇒ MessageFunction
Returns a new instance of MessageFunction.
4 5 6 |
# File 'app/models/message_function.rb', line 4 def initialize(name, description='') @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'app/models/message_function.rb', line 2 def name @name end |
Class Method Details
.[](value) ⇒ Object
24 25 26 27 |
# File 'app/models/message_function.rb', line 24 def self.[](value) return if value.blank? @@functions.find { |function| function.symbol == value.to_s.downcase.intern } end |
.add(name, description = '') ⇒ Object
29 30 31 |
# File 'app/models/message_function.rb', line 29 def self.add(name, description='') @@functions.push(MessageFunction.new(name, description)) unless MessageFunction[name] end |
.find_all ⇒ Object
33 34 35 |
# File 'app/models/message_function.rb', line 33 def self.find_all @@functions.dup end |
Instance Method Details
#description ⇒ Object
16 17 18 |
# File 'app/models/message_function.rb', line 16 def description I18n.t("message_functions.#{@name}") end |
#humanize ⇒ Object
20 21 22 |
# File 'app/models/message_function.rb', line 20 def humanize to_s.gsub('_', ' ') end |
#symbol ⇒ Object
8 9 10 |
# File 'app/models/message_function.rb', line 8 def symbol @name.to_s.downcase.intern end |
#to_s ⇒ Object
12 13 14 |
# File 'app/models/message_function.rb', line 12 def to_s @name end |