Class: SimpleAttribute::Attributes::Association
- Inherits:
-
Base
- Object
- Base
- SimpleAttribute::Attributes::Association
show all
- Defined in:
- lib/simple_attribute/attributes/association.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #options, #record, #value
Instance Method Summary
collapse
Methods inherited from Base
#default_value, #defaults, #html_options, #initialize, #method_missing, #render, #render_default_value, #render_with_default, #render_wrapper, #renderer_name, #value?, #wrapper, #wrapper?, #wrapper_html
Instance Method Details
#attribute_name ⇒ Object
4
5
6
|
# File 'lib/simple_attribute/attributes/association.rb', line 4
def attribute_name
'association'
end
|
#label_method ⇒ Object
8
9
10
|
# File 'lib/simple_attribute/attributes/association.rb', line 8
def label_method
@options.fetch(:label, :id)
end
|
#render_attribute ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/simple_attribute/attributes/association.rb', line 20
def render_attribute
label = value.try(label_method)
title = value.try(title_method)
unless url_method.nil?
value = @context.send(url_method, @value)
end
link_to label, value, html_options.merge(title: title)
end
|
#title_method ⇒ Object
12
13
14
|
# File 'lib/simple_attribute/attributes/association.rb', line 12
def title_method
@options.fetch(:title, :id)
end
|
#url_method ⇒ Object
16
17
18
|
# File 'lib/simple_attribute/attributes/association.rb', line 16
def url_method
@options.fetch(:url, nil)
end
|