Class: Instructions::Configuration
- Inherits:
-
Object
- Object
- Instructions::Configuration
- Defined in:
- lib/instructions/configuration.rb
Instance Attribute Summary collapse
-
#attribute_name_formatters ⇒ Object
readonly
Returns the value of attribute attribute_name_formatters.
-
#instructions_formatters ⇒ Object
readonly
Returns the value of attribute instructions_formatters.
Class Method Summary collapse
- .default_message_joiner ⇒ Object
- .formatters(attribute_state) ⇒ Object
- .instance ⇒ Object
- .message_joiner ⇒ Object
Instance Method Summary collapse
- #format_attribute_name(attribute_state, &block) ⇒ Object
- #format_instructions(attribute_state, &block) ⇒ Object
- #formatters(attribute_state) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #message_joiner(&block) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 |
# File 'lib/instructions/configuration.rb', line 6 def initialize @attribute_name_formatters = {} @instructions_formatters = {} end |
Instance Attribute Details
#attribute_name_formatters ⇒ Object (readonly)
Returns the value of attribute attribute_name_formatters.
3 4 5 |
# File 'lib/instructions/configuration.rb', line 3 def attribute_name_formatters @attribute_name_formatters end |
#instructions_formatters ⇒ Object (readonly)
Returns the value of attribute instructions_formatters.
4 5 6 |
# File 'lib/instructions/configuration.rb', line 4 def instructions_formatters @instructions_formatters end |
Class Method Details
.default_message_joiner ⇒ Object
11 12 13 |
# File 'lib/instructions/configuration.rb', line 11 def self. Proc.new { || .join ', ' } end |
.formatters(attribute_state) ⇒ Object
32 33 34 |
# File 'lib/instructions/configuration.rb', line 32 def self.formatters(attribute_state) instance.formatters attribute_state end |
.instance ⇒ Object
15 16 17 |
# File 'lib/instructions/configuration.rb', line 15 def self.instance @@instance ||= new end |
.message_joiner ⇒ Object
45 46 47 |
# File 'lib/instructions/configuration.rb', line 45 def self. instance. end |
Instance Method Details
#format_attribute_name(attribute_state, &block) ⇒ Object
19 20 21 |
# File 'lib/instructions/configuration.rb', line 19 def format_attribute_name(attribute_state, &block) @attribute_name_formatters[attribute_state] = block end |
#format_instructions(attribute_state, &block) ⇒ Object
23 24 25 |
# File 'lib/instructions/configuration.rb', line 23 def format_instructions(attribute_state, &block) @instructions_formatters[attribute_state] = block end |
#formatters(attribute_state) ⇒ Object
27 28 29 30 |
# File 'lib/instructions/configuration.rb', line 27 def formatters(attribute_state) {:attribute_name => @attribute_name_formatters[attribute_state], :instructions => @instructions_formatters[attribute_state]} end |
#message_joiner(&block) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/instructions/configuration.rb', line 36 def (&block) if block_given? = block else ||= self.class. end end |