Class: Interview::Attribute
- Defined in:
- lib/interview/attribute.rb
Direct Known Subclasses
AssociationAttribute, AssociationListAttribute, BooleanAttribute, ContainerAttribute, DateAttribute, DatetimeAttribute, DecimalAttribute, HiddenAttribute, HtmlTextAttribute, ImageAttribute, ImageGalleryAttribute, IntegerAttribute, OptionAttribute, StringAttribute, TextAttribute
Instance Attribute Summary collapse
-
#align ⇒ Object
Returns the value of attribute align.
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#hide_caption ⇒ Object
Returns the value of attribute hide_caption.
-
#hide_tooltip ⇒ Object
Returns the value of attribute hide_tooltip.
-
#html_class ⇒ Object
Returns the value of attribute html_class.
-
#link ⇒ Object
Returns the value of attribute link.
-
#method ⇒ Object
Returns the value of attribute method.
-
#nil_value ⇒ Object
Returns the value of attribute nil_value.
-
#on_changed ⇒ Object
Returns the value of attribute on_changed.
-
#only_for ⇒ Object
Returns the value of attribute only_for.
-
#style ⇒ Object
Returns the value of attribute style.
-
#surrounding_tag ⇒ Object
Returns the value of attribute surrounding_tag.
Attributes inherited from Control
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #render ⇒ Object
- #render_read ⇒ Object
- #render_write ⇒ Object
- #tooltip ⇒ Object
- #value ⇒ Object
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #set_attributes, #set_defaults
Constructor Details
#initialize(params = {}) ⇒ Attribute
Returns a new instance of Attribute.
7 8 9 10 |
# File 'lib/interview/attribute.rb', line 7 def initialize(params={}) @html_class = [] super end |
Instance Attribute Details
#align ⇒ Object
Returns the value of attribute align.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def align @align end |
#caption ⇒ Object
Returns the value of attribute caption.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def caption @caption end |
#hide_caption ⇒ Object
Returns the value of attribute hide_caption.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def hide_caption @hide_caption end |
#hide_tooltip ⇒ Object
Returns the value of attribute hide_tooltip.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def hide_tooltip @hide_tooltip end |
#html_class ⇒ Object
Returns the value of attribute html_class.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def html_class @html_class end |
#link ⇒ Object
Returns the value of attribute link.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def link @link end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def method @method end |
#nil_value ⇒ Object
Returns the value of attribute nil_value.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def nil_value @nil_value end |
#on_changed ⇒ Object
Returns the value of attribute on_changed.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def on_changed @on_changed end |
#only_for ⇒ Object
Returns the value of attribute only_for.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def only_for @only_for end |
#style ⇒ Object
Returns the value of attribute style.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def style @style end |
#surrounding_tag ⇒ Object
Returns the value of attribute surrounding_tag.
4 5 6 |
# File 'lib/interview/attribute.rb', line 4 def surrounding_tag @surrounding_tag end |
Instance Method Details
#render ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/interview/attribute.rb', line 36 def render return '' if hide? if @style and respond_to?("render_#{@style}_style", true) html = send("render_#{@style}_style") else html = render_default_style end return add_surrounding_tag(html) end |
#render_read ⇒ Object
47 48 49 |
# File 'lib/interview/attribute.rb', line 47 def render_read return value.to_s end |
#render_write ⇒ Object
51 52 53 |
# File 'lib/interview/attribute.rb', line 51 def render_write return form_builder.text_field @method, class: 'form-control' end |
#tooltip ⇒ Object
30 31 32 33 |
# File 'lib/interview/attribute.rb', line 30 def tooltip object = find_attribute! :object return h.t("activerecord.attribute_tooltips.#{object.class.model_name.i18n_key}.#{@method}", default: '') end |
#value ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/interview/attribute.rb', line 12 def value object = @object || find_attribute!(:object) if object.respond_to? @method val = object.send @method end val = @nil_value if val.nil? return val end |