Class: BrainDamage::View::Display::ForeignSinglePageManager

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

Instance Attribute Summary collapse

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) ⇒ ForeignSinglePageManager

Returns a new instance of ForeignSinglePageManager.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/brain_damage/lib/views/displays/foreign_single_page_manager.rb', line 12

def initialize(field, options)
  super

  default_options = {
    deletable: true,
    editable: true,
    viewable: false,
    explicit_form: false,
    leading_form: false,
    trailing_form: true,
    nested_on: resource_name_according_to_foreign.to_sym
  }

  @spm_options = default_options.merge(options).slice(*default_options.keys)

  @foreign_model_class_name = @field.relation.class_name.to_s
  @foreign_singular_table_name = @foreign_model_class_name.underscore.singularize
  @foreign_plural_table_name = @foreign_model_class_name.underscore.pluralize
end

Dynamic Method Handling

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

Instance Attribute Details

#foreign_model_class_nameObject (readonly)

Returns the value of attribute foreign_model_class_name.



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

def foreign_model_class_name
  @foreign_model_class_name
end

#foreign_plural_table_nameObject (readonly)

Returns the value of attribute foreign_plural_table_name.



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

def foreign_plural_table_name
  @foreign_plural_table_name
end

#foreign_singular_table_nameObject (readonly)

Returns the value of attribute foreign_singular_table_name.



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

def foreign_singular_table_name
  @foreign_singular_table_name
end

Instance Method Details

#options_hashObject



40
41
42
# File 'lib/generators/brain_damage/lib/views/displays/foreign_single_page_manager.rb', line 40

def options_hash
  @spm_options.dup
end

#resource_name_according_to_foreignObject



32
33
34
35
36
37
38
# File 'lib/generators/brain_damage/lib/views/displays/foreign_single_page_manager.rb', line 32

def resource_name_according_to_foreign
  if @field.relation
    @field.relation.resource_name_according_to_foreign
  else
    singular_table_name
  end
end