Class: Toolbox::ShowConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/toolbox/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name, config) ⇒ ShowConfig

Returns a new instance of ShowConfig.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/toolbox/config.rb', line 52

def initialize model_name, config
  @fieldsets = []
  config[:fieldsets].each do |fieldset|
    h = {}
    h.merge! fieldset
    h[:widget_list] = WidgetList.new(model_name, fieldset[:widget_list], fieldset[:widget_type] || FieldConfig)
    h[:collection_config] = CollectionConfig.new fieldset[:collection_config] if fieldset[:collection_config]
    @fieldsets << WidgetSetConfig.new(h)
  end
  @embedded_lists = []
  prefixes = {}
  config[:embedded_lists] = config[:embedded_lists] || []
  config[:embedded_lists].each do |list|
    h = {}
    h.merge! list
    h[:collection_config] = CollectionConfig.new list[:collection_config]
    h[:widget_list] = WidgetList.new(h[:collection_config].type.name, list[:widget_list], FieldConfig)
    c = EmbeddedListConfig.new(h)
    raise "Prefix #{c.prefix} is already used by #{prefixes[c.prefix].label}" if prefixes[c.prefix]
    prefixes[c.prefix] = c
    @embedded_lists << c
  end
  @pdf_options = config[:pdf_options] || {}
end

Instance Attribute Details

#embedded_listsObject (readonly)

Returns the value of attribute embedded_lists.



49
50
51
# File 'lib/toolbox/config.rb', line 49

def embedded_lists
  @embedded_lists
end

#fieldsetsObject (readonly)

Returns the value of attribute fieldsets.



48
49
50
# File 'lib/toolbox/config.rb', line 48

def fieldsets
  @fieldsets
end

#pdf_optionsObject (readonly)

Returns the value of attribute pdf_options.



50
51
52
# File 'lib/toolbox/config.rb', line 50

def pdf_options
  @pdf_options
end