Class: Storefront::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/storefront/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/storefront/configuration.rb', line 88

def initialize
  @component_suffix                         = "widget"
  @hint_class                               = "hint"
  @hint_tag                                 = :figure
  @label_class                              = "label"
  @required_class                           = "required"
  @required_abbr                            = "*"
  @required_title                           = "Required"
  @error_class                              = "error"
  @error_tag                                = :output
  @valid_class                              = nil
  @optional_class                           = "optional"
  @optional_abbr                            = ""
  @optional_title                           = "Optional"
  @label_method                             = :humanize
  @label_attribute                          = :to_label
  @validation_max_limit                     = 255
  @default_text_field_size                  = nil
  @default_text_area_width                  = 300
  @all_fields_required_by_default           = true
  @field_list_tag                           = :ol
  @list_class                               = "field-list"
  @separator                                = "-"
  @breadcrumb                               = " - "
  @include_blank_for_select_by_default      = true
  @collection_label_methods                 = %w(to_label display_name full_name name title to_s)
  @i18n_lookups_by_default                  = true
  @escape_html_entities_in_hints_and_labels = false
  @rename_nested_attributes                 = true
  @inline_validations                       = true
  @auto_id_form                             = true
  @fieldset_class                           = "fieldset"
  @field_class                              = "field"
  @validate_class                           = "validate"
  @legend_class                             = "legend"
  @form_class                               = "form"
  @id_enabled_on                            = ["input"] # %w(field label error hint)
  @widgets_path                             = "shared/widgets"
  @nav_class                                = "list-item"
  @include_aria                             = true
  @active_class                             = "active"
  @nav_tag                                  = :li
  @terms_tag                                = :dl
  @term_class                               = "term"
  @term_key_class                           = "key"
  @term_value_class                         = "value"
  @hint_is_popup                            = false
  @list_tag                                 = :ul
  @page_header_id                           = "header"
  @page_title_id                            = "title"
  @auto_id_nav                              = false
  @page_subtitle_id                         = "subtitle"
  @widget_class                             = "widget"
  @header_class                             = "header"
  @title_class                              = "title"
  @subtitle_class                           = "subtitle"
  @content_class                            = "content"
  @default_header_level                     = 3
  @term_separator                           = ":"
  @rich_input                               = false
  @submit_fieldset_class                    = "submit-fieldset"
  @add_label                                = "+"
  @remove_label                             = "-"
  @cycle_fields                             = false
  @always_include_hint_tag                  = false
  @always_include_error_tag                 = true
  @require_if_validates_presence            = true
  @localize_with_namespace                  = false
  @localize_with_nested_model               = false
  @localize_with_inheritance                = true
  @default_component_header_level           = 3
  @meta_tags                                = [
    :description,
    :keywords,
    :author,
    :copyright,
    :category,
    :robots
  ]
end

Instance Attribute Details

#active_classObject

Returns the value of attribute active_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def active_class
  @active_class
end

#add_labelObject

Returns the value of attribute add_label.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def add_label
  @add_label
end

#all_fields_required_by_defaultObject

Returns the value of attribute all_fields_required_by_default.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def all_fields_required_by_default
  @all_fields_required_by_default
end

#always_include_error_tagObject

Returns the value of attribute always_include_error_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def always_include_error_tag
  @always_include_error_tag
end

#always_include_hint_tagObject

Returns the value of attribute always_include_hint_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def always_include_hint_tag
  @always_include_hint_tag
end

#auto_id_formObject

Returns the value of attribute auto_id_form.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def auto_id_form
  @auto_id_form
end

#auto_id_navObject

Returns the value of attribute auto_id_nav.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def auto_id_nav
  @auto_id_nav
end

Returns the value of attribute breadcrumb.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def breadcrumb
  @breadcrumb
end

#collection_label_methodsObject

Returns the value of attribute collection_label_methods.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def collection_label_methods
  @collection_label_methods
end

#component_suffixObject

Returns the value of attribute component_suffix.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def component_suffix
  @component_suffix
end

#content_classObject

Returns the value of attribute content_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def content_class
  @content_class
end

#cycle_fieldsObject

Returns the value of attribute cycle_fields.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def cycle_fields
  @cycle_fields
end

#default_component_header_levelObject

Returns the value of attribute default_component_header_level.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def default_component_header_level
  @default_component_header_level
end

#default_header_levelObject

Returns the value of attribute default_header_level.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def default_header_level
  @default_header_level
end

#default_text_area_widthObject

Returns the value of attribute default_text_area_width.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def default_text_area_width
  @default_text_area_width
end

#default_text_field_sizeObject

Returns the value of attribute default_text_field_size.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def default_text_field_size
  @default_text_field_size
end

#definition_list_partialObject

Returns the value of attribute definition_list_partial.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def definition_list_partial
  @definition_list_partial
end

#error_classObject

Returns the value of attribute error_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def error_class
  @error_class
end

#error_tagObject

Returns the value of attribute error_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def error_tag
  @error_tag
end

#fieldObject

Returns the value of attribute field.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def field
  @field
end

#field_classObject

Returns the value of attribute field_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def field_class
  @field_class
end

#field_list_tagObject

Returns the value of attribute field_list_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def field_list_tag
  @field_list_tag
end

#fieldset_classObject

Returns the value of attribute fieldset_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def fieldset_class
  @fieldset_class
end

#form_classObject

Returns the value of attribute form_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def form_class
  @form_class
end

#header_classObject

Returns the value of attribute header_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def header_class
  @header_class
end

#hint_classObject

Returns the value of attribute hint_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def hint_class
  @hint_class
end

#hint_is_popupObject

Returns the value of attribute hint_is_popup.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def hint_is_popup
  @hint_is_popup
end

#hint_tagObject

Returns the value of attribute hint_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def hint_tag
  @hint_tag
end

#i18n_lookups_by_defaultObject

Returns the value of attribute i18n_lookups_by_default.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def i18n_lookups_by_default
  @i18n_lookups_by_default
end

#id_enabled_onObject

Returns the value of attribute id_enabled_on.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def id_enabled_on
  @id_enabled_on
end

#include_ariaObject

Returns the value of attribute include_aria.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def include_aria
  @include_aria
end

#include_blank_for_select_by_defaultObject

Returns the value of attribute include_blank_for_select_by_default.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def include_blank_for_select_by_default
  @include_blank_for_select_by_default
end

#inline_validationsObject

Returns the value of attribute inline_validations.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def inline_validations
  @inline_validations
end

#label_attributeObject

Returns the value of attribute label_attribute.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def label_attribute
  @label_attribute
end

#label_classObject

Returns the value of attribute label_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def label_class
  @label_class
end

#label_methodObject

Returns the value of attribute label_method.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def label_method
  @label_method
end

#legend_classObject

Returns the value of attribute legend_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def legend_class
  @legend_class
end

#list_classObject

Returns the value of attribute list_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def list_class
  @list_class
end

#list_partialObject

Returns the value of attribute list_partial.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def list_partial
  @list_partial
end

#list_tagObject

Returns the value of attribute list_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def list_tag
  @list_tag
end

#localize_with_inheritanceObject

Returns the value of attribute localize_with_inheritance.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def localize_with_inheritance
  @localize_with_inheritance
end

#localize_with_namespaceObject

Returns the value of attribute localize_with_namespace.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def localize_with_namespace
  @localize_with_namespace
end

#localize_with_nested_modelObject

Returns the value of attribute localize_with_nested_model.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def localize_with_nested_model
  @localize_with_nested_model
end

#meta_tagsObject

Returns the value of attribute meta_tags.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def meta_tags
  @meta_tags
end

Returns the value of attribute nav_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def nav_class
  @nav_class
end

Returns the value of attribute nav_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def nav_tag
  @nav_tag
end

#optional_abbrObject

Returns the value of attribute optional_abbr.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def optional_abbr
  @optional_abbr
end

#optional_classObject

Returns the value of attribute optional_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def optional_class
  @optional_class
end

#optional_titleObject

Returns the value of attribute optional_title.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def optional_title
  @optional_title
end

#page_header_idObject

Returns the value of attribute page_header_id.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def page_header_id
  @page_header_id
end

#page_subtitle_idObject

Returns the value of attribute page_subtitle_id.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def page_subtitle_id
  @page_subtitle_id
end

#page_title_idObject

Returns the value of attribute page_title_id.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def page_title_id
  @page_title_id
end

#remove_labelObject

Returns the value of attribute remove_label.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def remove_label
  @remove_label
end

#rename_nested_attributesObject

Returns the value of attribute rename_nested_attributes.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def rename_nested_attributes
  @rename_nested_attributes
end

#require_if_validates_presenceObject

Returns the value of attribute require_if_validates_presence.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def require_if_validates_presence
  @require_if_validates_presence
end

#required_abbrObject

Returns the value of attribute required_abbr.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def required_abbr
  @required_abbr
end

#required_classObject

Returns the value of attribute required_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def required_class
  @required_class
end

#required_titleObject

Returns the value of attribute required_title.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def required_title
  @required_title
end

#rich_inputObject

Returns the value of attribute rich_input.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def rich_input
  @rich_input
end

#separatorObject

Returns the value of attribute separator.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def separator
  @separator
end

#submit_fieldset_classObject

Returns the value of attribute submit_fieldset_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def submit_fieldset_class
  @submit_fieldset_class
end

#subtitle_classObject

Returns the value of attribute subtitle_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def subtitle_class
  @subtitle_class
end

#term_classObject

Returns the value of attribute term_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def term_class
  @term_class
end

#term_key_classObject

Returns the value of attribute term_key_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def term_key_class
  @term_key_class
end

#term_separatorObject

Returns the value of attribute term_separator.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def term_separator
  @term_separator
end

#term_value_classObject

Returns the value of attribute term_value_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def term_value_class
  @term_value_class
end

#terms_tagObject

Returns the value of attribute terms_tag.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def terms_tag
  @terms_tag
end

#title_classObject

Returns the value of attribute title_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def title_class
  @title_class
end

#valid_classObject

Returns the value of attribute valid_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def valid_class
  @valid_class
end

#validate_classObject

Returns the value of attribute validate_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def validate_class
  @validate_class
end

#validation_max_limitObject

Returns the value of attribute validation_max_limit.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def validation_max_limit
  @validation_max_limit
end

#widget_classObject

Returns the value of attribute widget_class.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def widget_class
  @widget_class
end

#widgets_pathObject

Returns the value of attribute widgets_path.



13
14
15
# File 'lib/storefront/configuration.rb', line 13

def widgets_path
  @widgets_path
end

Instance Method Details

#configure_action_controllerObject



190
191
192
193
194
195
196
197
198
199
200
# File 'lib/storefront/configuration.rb', line 190

def configure_action_controller
  base = "#{File.expand_path(File.dirname(__FILE__))}/helpers"
  Dir["#{base}/*"].each do |path|
    next if File.directory?(path) || File.basename(path) =~ /(form|table|dashboard)/
    # need to do these as traditional helper declarations somehow
    constant_name = File.basename(path, File.extname(path)).gsub("/", "::").camelize
    ActionController::Base.send :include, "Storefront::Helpers::#{constant_name}".constantize
  end
  
  ActionController::Base.send :before_filter, :configure_storefront
end

#configure_action_viewObject



181
182
183
184
185
186
187
188
# File 'lib/storefront/configuration.rb', line 181

def configure_action_view
  base = "#{File.expand_path(File.dirname(__FILE__))}/helpers"
  Dir["#{base}/*"].each do |path|
    next if File.directory?(path)
    constant_name = File.basename(path, File.extname(path)).gsub("/", "::").camelize
    ActionView::Base.send :include, "Storefront::Helpers::#{constant_name}".constantize
  end
end

#current_scopeObject



173
174
175
# File 'lib/storefront/configuration.rb', line 173

def current_scope
  Thread.current[:storefront]
end

#current_scope=(value) ⇒ Object



177
178
179
# File 'lib/storefront/configuration.rb', line 177

def current_scope=(value)
  Thread.current[:storefront] = value
end

#get(key) ⇒ Object



169
170
171
# File 'lib/storefront/configuration.rb', line 169

def get(key)
  send(key).respond_to?(:call) ? send(key).call : send(key)
end