Class: BrainDamage::Templateable::FieldTemplateable

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/brain_damage/lib/templateable/field_templateable.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#inner_html, #options, #template_file

Instance Method Summary collapse

Methods inherited from Base

#indent, #render_erb_file, #render_erb_string, #render_template_file

Constructor Details

#initialize(field, options) ⇒ FieldTemplateable

Returns a new instance of FieldTemplateable.



9
10
11
12
13
14
15
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 9

def initialize(field, options)
  @field = field
  @type = self.class.to_s.split('::').last.underscore.to_sym

  resource = field.resource
  super resource, options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



21
22
23
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 21

def method_missing(method, *args, &block)
  @field.send method, *args, &block
end

Instance Attribute Details

#partial_htmlObject (readonly)

Returns the value of attribute partial_html.



7
8
9
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 7

def partial_html
  @partial_html
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 6

def type
  @type
end

Instance Method Details

#empty_haml_pathObject



17
18
19
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 17

def empty_haml_path
  'brain_damage/empty'
end

#label_guard?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 25

def label_guard?
  false
end

#renderObject



37
38
39
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 37

def render
  super
end

#show?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 33

def show?
  true
end

#show_label?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/generators/brain_damage/lib/templateable/field_templateable.rb', line 29

def show_label?
  true
end