Class: Linkificator::ConditionsStorage
- Inherits:
-
Object
- Object
- Linkificator::ConditionsStorage
- Defined in:
- lib/linkificator/conditions_storage.rb
Defined Under Namespace
Classes: Condition
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #condition_for(options = {}) ⇒ Object
-
#initialize(conditions, options = {}) ⇒ ConditionsStorage
constructor
A new instance of ConditionsStorage.
- #link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
Constructor Details
#initialize(conditions, options = {}) ⇒ ConditionsStorage
Returns a new instance of ConditionsStorage.
7 8 9 10 |
# File 'lib/linkificator/conditions_storage.rb', line 7 def initialize(conditions, ={}) @conditions = conditions.map { |hash| Condition.new(hash.merge()) } @options = end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/linkificator/conditions_storage.rb', line 5 def conditions @conditions end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/linkificator/conditions_storage.rb', line 5 def @options end |
Instance Method Details
#condition_for(options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/linkificator/conditions_storage.rb', line 12 def condition_for(={}) @conditions.detect do |condition| condition if condition.match?() end end |
#link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/linkificator/conditions_storage.rb', line 18 def link_to(name = nil, = nil, = nil, &block) context = extract_context(name, , , &block) condition = condition_for(context) || Condition.new(self.) condition.link_to(name, , , &block) end |