Class: Relevance::Tarantula::Link
- Extended by:
- ActionView::Helpers::UrlHelper
- Defined in:
- lib/relevance/tarantula/link.rb
Constant Summary collapse
- METHOD_REGEXPS =
{}
Instance Attribute Summary collapse
-
#href ⇒ Object
Returns the value of attribute href.
Class Method Summary collapse
-
.protect_against_forgery? ⇒ Boolean
method_javascript_function needs this method.
Instance Method Summary collapse
- #==(obj) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(link) ⇒ Link
constructor
A new instance of Link.
- #method ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(link) ⇒ Link
Returns a new instance of Link.
22 23 24 25 26 27 28 29 30 |
# File 'lib/relevance/tarantula/link.rb', line 22 def initialize(link) if String === link || link.nil? @href = link @method = :get else # should be a tag @href = link['href'] ? link['href'].downcase : nil @tag = link end end |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
20 21 22 |
# File 'lib/relevance/tarantula/link.rb', line 20 def href @href end |
Class Method Details
.protect_against_forgery? ⇒ Boolean
method_javascript_function needs this method
6 7 8 |
# File 'lib/relevance/tarantula/link.rb', line 6 def protect_against_forgery? false end |
Instance Method Details
#==(obj) ⇒ Object Also known as: eql?
42 43 44 45 |
# File 'lib/relevance/tarantula/link.rb', line 42 def ==(obj) obj.respond_to?(:href) && obj.respond_to?(:method) && self.href.to_s == obj.href.to_s && self.method.to_s == obj.method.to_s end |
#hash ⇒ Object
48 49 50 |
# File 'lib/relevance/tarantula/link.rb', line 48 def hash to_s.hash end |
#method ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/relevance/tarantula/link.rb', line 32 def method @method ||= begin (@tag && [:put, :delete, :post].detect do |m| # post should be last since it's least specific @tag['onclick'] =~ METHOD_REGEXPS[m] end) || :get end end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/relevance/tarantula/link.rb', line 52 def to_s "<Relevance::Tarantula::Link href=#{href}, method=#{method}>" end |