Class: BrainDamage::View::Display::Text

Inherits:
Base show all
Defined in:
lib/generators/brain_damage/lib/views/displays/text.rb

Instance Attribute Summary

Attributes inherited from Templateable::FieldTemplateable

#partial_html, #type

Attributes inherited from Templateable::Base

#inner_html, #options, #template_file

Instance Method Summary collapse

Methods inherited from Base

#dir

Methods inherited from Templateable::FieldTemplateable

#empty_haml_path, #label_guard?, #method_missing, #render, #show?, #show_label?

Methods inherited from Templateable::Base

#indent, #method_missing, #render, #render_erb_file, #render_erb_string, #render_template_file

Constructor Details

#initialize(field, options) ⇒ Text

Returns a new instance of Text.



8
9
10
11
12
# File 'lib/generators/brain_damage/lib/views/displays/text.rb', line 8

def initialize(field, options)
  super
  @display_method = options[:display_method] || name
  @target_method = options[:target_method] || name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BrainDamage::Templateable::FieldTemplateable

Instance Method Details

#display_textObject



22
23
24
25
26
27
28
29
30
# File 'lib/generators/brain_damage/lib/views/displays/text.rb', line 22

def display_text
  inner_text = text

  if @options[:filter_method]
    "#{inner_text}.#{@options[:filter_method]}"
  else
    inner_text
  end
end

#include_existance_check?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/generators/brain_damage/lib/views/displays/text.rb', line 37

def include_existance_check?
  foreign?
end

#targetObject



32
33
34
35
# File 'lib/generators/brain_damage/lib/views/displays/text.rb', line 32

def target
  return "#{singular_table_name}.#{@target_method}" if foreign?
  "#{singular_table_name}"
end

#textObject



14
15
16
17
18
19
20
# File 'lib/generators/brain_damage/lib/views/displays/text.rb', line 14

def text
  if foreign?
    "#{singular_table_name}.#{@target_method}.#{@display_method}"
  else
    "#{singular_table_name}.#{@display_method}"
  end
end