Class: Interview::Link
- Includes:
- HasHtmlOptions, NestedBuildable
- Defined in:
- lib/interview/controls/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.
-
#assoc_object ⇒ Object
Returns the value of attribute assoc_object.
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#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.
-
#new_site ⇒ Object
Returns the value of attribute new_site.
-
#object ⇒ Object
Returns the value of attribute object.
-
#options ⇒ Object
Returns the value of attribute options.
-
#style ⇒ Object
Returns the value of attribute style.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_params ⇒ Object
readonly
Returns the value of attribute url_params.
Attributes included from HasHtmlOptions
Attributes inherited from Control
Instance Method Summary collapse
- #build(b) ⇒ Object
-
#initialize(params = {}) ⇒ Link
constructor
A new instance of Link.
Methods included from NestedBuildable
#create_nested_builder, #render_nested_builder
Methods inherited from Control
#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #set_attributes, #set_defaults
Constructor Details
#initialize(params = {}) ⇒ Link
Returns a new instance of Link.
11 12 13 14 |
# File 'lib/interview/controls/link.rb', line 11 def initialize(params={}) @options = {} super end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def action @action end |
#active ⇒ Object
Returns the value of attribute active.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def active @active end |
#assoc_object ⇒ Object
Returns the value of attribute assoc_object.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def assoc_object @assoc_object end |
#caption ⇒ Object
Returns the value of attribute caption.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def @caption end |
#hint ⇒ Object
Returns the value of attribute hint.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def hint @hint end |
#http_method ⇒ Object
Returns the value of attribute http_method.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def http_method @http_method end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def image @image end |
#nested_resource ⇒ Object
Returns the value of attribute nested_resource.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def nested_resource @nested_resource end |
#new_site ⇒ Object
Returns the value of attribute new_site.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def new_site @new_site end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def object @object end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def @options end |
#style ⇒ Object
Returns the value of attribute style.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def style @style end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/interview/controls/link.rb', line 6 def url @url end |
#url_params ⇒ Object (readonly)
Returns the value of attribute url_params.
9 10 11 |
# File 'lib/interview/controls/link.rb', line 9 def url_params @url_params end |
Instance Method Details
#build(b) ⇒ Object
16 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 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/interview/controls/link.rb', line 16 def build(b) = @html_options.dup html_class = @html_class.dup url = get_url if @action == 'destroy' [:method] = :delete [:data] = {} unless [:data] [:data][:confim] = 'Are you sure?' # todo end if @http_method [:method] = @http_method.to_sym end if @hint [:title] = @hint end if @style == 'button' html_class += %w(btn btn-default) elsif @style == 'primary_button' html_class += %w(btn btn-primary) end if @new_site [:target] = 'blank' end add_list_item(b) do b << h.link_to(url, (, html_class)) do create_nested_builder(b) b.glyphicon image: @image if @image b.space if @image and @caption b.text text: @caption if @caption yield if block_given? render_nested_builder(b) end end end |