Class: Interview::Attribute

Inherits:
Control
  • Object
show all
Defined in:
lib/interview/attribute.rb

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

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

#alignObject

Returns the value of attribute align.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def align
  @align
end

#captionObject

Returns the value of attribute caption.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def caption
  @caption
end

#hide_captionObject

Returns the value of attribute hide_caption.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def hide_caption
  @hide_caption
end

#hide_tooltipObject

Returns the value of attribute hide_tooltip.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def hide_tooltip
  @hide_tooltip
end

#html_classObject

Returns the value of attribute html_class.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def html_class
  @html_class
end

Returns the value of attribute link.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def link
  @link
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def method
  @method
end

#nil_valueObject

Returns the value of attribute nil_value.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def nil_value
  @nil_value
end

#on_changedObject

Returns the value of attribute on_changed.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def on_changed
  @on_changed
end

#only_forObject

Returns the value of attribute only_for.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def only_for
  @only_for
end

#styleObject

Returns the value of attribute style.



4
5
6
# File 'lib/interview/attribute.rb', line 4

def style
  @style
end

#surrounding_tagObject

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

#renderObject



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_readObject



47
48
49
# File 'lib/interview/attribute.rb', line 47

def render_read
  return value.to_s
end

#render_writeObject



51
52
53
# File 'lib/interview/attribute.rb', line 51

def render_write
  return form_builder.text_field @method, class: 'form-control'
end

#tooltipObject



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

#valueObject



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