Class: Linkificator::ConditionsStorage::Condition
- Inherits:
-
Object
- Object
- Linkificator::ConditionsStorage::Condition
- Defined in:
- lib/linkificator/conditions_storage/condition.rb
Defined Under Namespace
Classes: ViewContext
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Condition
constructor
A new instance of Condition.
- #link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
- #match?(options) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Condition
Returns a new instance of Condition.
4 5 6 |
# File 'lib/linkificator/conditions_storage/condition.rb', line 4 def initialize(={}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/linkificator/conditions_storage/condition.rb', line 2 def @options end |
Instance Method Details
#link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/linkificator/conditions_storage/condition.rb', line 17 def link_to(name = nil, = nil, = nil, &block) , , name = , name, block if block_given? ||= {} view_context = view_context(( || {}).delete(:view_context)) if processing[:data_href] url = view_context.url_for(*) = ( || {}).merge('href' => '#', 'data-href' => Base64.strict_encode64(url)) end if processing[:rel_nofollow] = ( || {}).merge(rel: 'nofollow') end link = if block_given? call_link_method(view_context, , , &block) else call_link_method(view_context, name, , ) end if processing[:wrap_noindex] view_context.content_tag(:noindex) { link } else link end end |
#match?(options) ⇒ Boolean
8 9 10 11 12 13 14 15 |
# File 'lib/linkificator/conditions_storage/condition.rb', line 8 def match?() [ context[:target] ? detect_presence(context[:target], [:target]) : true, context[:target_not] ? !detect_presence(context[:target_not], [:target]) : true, context[:current] ? detect_presence(context[:current], [:current]) : true, context[:current_not] ? !detect_presence(context[:current_not], [:current]) : true, ].all? end |