Class: Interview::Link
- Includes:
- HasControls
- Defined in:
- lib/interview/link.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#active ⇒ Object
Returns the value of attribute active.
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#html_class ⇒ Object
readonly
Returns the value of attribute html_class.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#image ⇒ Object
Returns the value of attribute image.
-
#nested_resource ⇒ Object
Returns the value of attribute nested_resource.
-
#object ⇒ Object
todo: Überdenken.
-
#redirect_to ⇒ Object
Returns the value of attribute redirect_to.
-
#style ⇒ Object
Returns the value of attribute style.
-
#trail ⇒ Object
Returns the value of attribute trail.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_params ⇒ Object
readonly
Returns the value of attribute url_params.
Attributes included from HasControls
Attributes inherited from Control
Instance Method Summary collapse
-
#assoc_object ⇒ Object
todo: Überdenken.
- #filter=(filter) ⇒ Object
-
#initialize(params = {}) ⇒ Link
constructor
A new instance of Link.
- #render ⇒ Object
- #scope=(scope) ⇒ Object
Methods included from HasControls
#add_control, #add_controls, included, #siblings
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #set_attributes, #set_defaults
Constructor Details
#initialize(params = {}) ⇒ Link
Returns a new instance of Link.
9 10 11 12 13 |
# File 'lib/interview/link.rb', line 9 def initialize(params={}) @html_class = [] @url_params = {} super end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def action @action end |
#active ⇒ Object
Returns the value of attribute active.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def active @active end |
#caption ⇒ Object
Returns the value of attribute caption.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def caption @caption end |
#controller ⇒ Object
Returns the value of attribute controller.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def controller @controller end |
#hint ⇒ Object
Returns the value of attribute hint.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def hint @hint end |
#html_class ⇒ Object (readonly)
Returns the value of attribute html_class.
7 8 9 |
# File 'lib/interview/link.rb', line 7 def html_class @html_class end |
#http_method ⇒ Object
Returns the value of attribute http_method.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def http_method @http_method end |
#image ⇒ Object
Returns the value of attribute image.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def image @image end |
#nested_resource ⇒ Object
Returns the value of attribute nested_resource.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def nested_resource @nested_resource end |
#object ⇒ Object
todo: Überdenken
82 83 84 |
# File 'lib/interview/link.rb', line 82 def object @object end |
#redirect_to ⇒ Object
Returns the value of attribute redirect_to.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def redirect_to @redirect_to end |
#style ⇒ Object
Returns the value of attribute style.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def style @style end |
#trail ⇒ Object
Returns the value of attribute trail.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def trail @trail end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/interview/link.rb', line 5 def url @url end |
#url_params ⇒ Object (readonly)
Returns the value of attribute url_params.
7 8 9 |
# File 'lib/interview/link.rb', line 7 def url_params @url_params end |
Instance Method Details
#assoc_object ⇒ Object
todo: Überdenken
86 87 88 |
# File 'lib/interview/link.rb', line 86 def assoc_object # todo: Überdenken find_attribute(:assoc_object) end |
#filter=(filter) ⇒ Object
19 20 21 |
# File 'lib/interview/link.rb', line 19 def filter=(filter) @url_params[:filter] = filter end |
#render ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/interview/link.rb', line 23 def render if @redirect_to if @redirect_to == :current @url_params[:redirect_to] = h.request.original_url elsif @redirect_to == :parent and Object.const_defined? 'Gretel' @url_params[:redirect_to] = h..url else @url_params[:redirect_to] = @redirect_to end end if @trail and Object.const_defined? 'Gretel' @url_params[:trail] = h. end if @url url = @url url = "#{h.root_url}#{url}" if url[0..3] != 'http' elsif @controller = @url_option.dup opts = {controller: @controller, action: @action}.merge @url_params url = h.url_for opts else url_params = @url_params.dup url_params[:action] = @action if @action and not %w(index show create update destroy).include? @action object = @object || find_attribute!(:object) url_params.each do |key, value| url_params[key] = value.call(self) if value.is_a? Proc end if @nested_resource and assoc_object url = h.polymorphic_path [assoc_object, object], url_params else url = h.polymorphic_path object, url_params end end = {} html_class = @html_class.dup if @action == 'destroy' [:method] = :delete [:data] = { confirm: 'Are you sure?' } end if @http_method [:method] = @http_method.to_sym end if @hint html_class << 'action_hint' [:'data-toggle'] = 'tooltip' [:title] = @hint end if @style and respond_to? "render_#{@style}_style", true return send "render_#{@style}_style", url, html_class, else return render_link url, html_class, end end |
#scope=(scope) ⇒ Object
15 16 17 |
# File 'lib/interview/link.rb', line 15 def scope=(scope) @url_params[:scope] = scope end |