Class: ConditionalMessages::Category
- Inherits:
-
Object
- Object
- ConditionalMessages::Category
- Defined in:
- lib/conditional_messages/category.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #apply(context_holder) ⇒ Object
- #define(*args, &definition) ⇒ Object
-
#initialize(name) ⇒ Category
constructor
A new instance of Category.
- #message(source_text, &definition) ⇒ Object
- #messages ⇒ Object
Constructor Details
#initialize(name) ⇒ Category
Returns a new instance of Category.
8 9 10 |
# File 'lib/conditional_messages/category.rb', line 8 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/conditional_messages/category.rb', line 6 def name @name end |
Instance Method Details
#apply(context_holder) ⇒ Object
28 29 30 |
# File 'lib/conditional_messages/category.rb', line 28 def apply(context_holder) .map { || .apply(context_holder) } end |
#define(*args, &definition) ⇒ Object
12 13 14 15 |
# File 'lib/conditional_messages/category.rb', line 12 def define(*args, &definition) instance_eval(*args, &definition) self end |
#message(source_text, &definition) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/conditional_messages/category.rb', line 17 def (source_text, &definition) = Message.new(source_text) .define(&definition) if definition << end |
#messages ⇒ Object
24 25 26 |
# File 'lib/conditional_messages/category.rb', line 24 def ||= [] end |