Module: Listly
- Defined in:
- lib/listly.rb,
lib/listly/lists.rb,
lib/listly/railtie.rb,
lib/listly/version.rb,
lib/listly/base_list.rb,
lib/listly/list_constants.rb
Overview
The config class allows the Rails Application to store configuration about the gem
Defined Under Namespace
Modules: BaseList, ListConstants Classes: Config, Railtie
Constant Summary collapse
- VERSION =
"0.1.5"
Class Method Summary collapse
- .class_name_for_item_name(name) ⇒ Object
- .config ⇒ Object
- .configure {|self.config| ... } ⇒ Object
-
.include_constants_module ⇒ Object
List Class Names as Constants.
-
.list_name_constants ⇒ Object
Returns a hash of class names to hash storage details as sym.
-
.module_name_for_list_name(name) ⇒ Object
Returns a module name from a constant name.
Class Method Details
.class_name_for_item_name(name) ⇒ Object
33 34 35 |
# File 'lib/listly/lists.rb', line 33 def class_name_for_item_name(name) class_name = name.to_s.titleize.gsub(' ', '') end |
.config ⇒ Object
15 16 17 |
# File 'lib/listly.rb', line 15 def self.config @@config ||= Config.new end |
.configure {|self.config| ... } ⇒ Object
19 20 21 |
# File 'lib/listly.rb', line 19 def self.configure yield self.config end |
.include_constants_module ⇒ Object
List Class Names as Constants
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/listly/lists.rb', line 8 def include_constants_module constants_module_sym = Listly.config.listly_constants_module constants_module_str = constants_module_sym.to_s.titleize.gsub(' ', '') constants_module = Module.const_get(constants_module_str) unless constants_module_str.length == 0 if constants_module self.send(:include, constants_module) else self.send(:include, Listly::ListConstants) end end |
.list_name_constants ⇒ Object
Returns a hash of class names to hash storage details as sym.
20 21 22 23 24 25 26 |
# File 'lib/listly/lists.rb', line 20 def list_name_constants self.constants.each_with_object({}) do |name, hash| # Ignore any class constants next if (storage_location = Listly.const_get(name)).is_a?(Module) hash[name] = storage_location end end |
.module_name_for_list_name(name) ⇒ Object
Returns a module name from a constant name.
29 30 31 |
# File 'lib/listly/lists.rb', line 29 def module_name_for_list_name(name) module_name = name.to_s.titleize.gsub(' ', '') end |