Module: Lazier
- Defined in:
- lib/lazier.rb,
lib/lazier/hash.rb,
lib/lazier/i18n.rb,
lib/lazier/math.rb,
lib/lazier/string.rb,
lib/lazier/object.rb,
lib/lazier/boolean.rb,
lib/lazier/version.rb,
lib/lazier/datetime.rb,
lib/lazier/settings.rb,
lib/lazier/pathname.rb,
lib/lazier/localizer.rb,
lib/lazier/exceptions.rb,
lib/lazier/configuration.rb
Overview
This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>. Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
Defined Under Namespace
Modules: Boolean, DateTime, Exceptions, Hash, I18n, Math, Object, Pathname, String, TimeZone, Version Classes: Configuration, Localizer, Settings
Class Method Summary (collapse)
-
+ (Class) find_class(cls, scope = "::%CLASS%", only_in_scope = false)
Finds a class to instantiate.
-
+ (Settings) load!(*what)
Loads the extensions.
-
+ (Object) load_boolean
Loads Boolean extensions.
-
+ (Object) load_datetime
Loads DateTime extensions.
-
+ (Object) load_hash
Loads Hash extensions.
-
+ (Object) load_math
Loads Math extensions.
-
+ (Object) load_object
Loads Object extensions.
-
+ (Object) load_pathname
Loads Pathname extensions.
-
+ (Object) load_string
Loads String extensions.
-
+ (Settings) settings
Returns the settings for the extensions.
Class Method Details
+ (Class) find_class(cls, scope = "::%CLASS%", only_in_scope = false)
Finds a class to instantiate.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/lazier.rb', line 115 def self.find_class(cls, scope = "::%CLASS%", only_in_scope = false) if cls.is_a?(::String) || cls.is_a?(::Symbol) then rv = nil cls = cls.to_s.camelize if only_in_scope then cls.gsub!(/^::/, "") # Mark only search only inside scope else rv = search_class(cls) # Search outside scope end rv = search_class(scope.to_s.gsub("%CLASS%", cls)) if !rv && cls !~ /^::/ && scope.present? # Search inside scope rv || raise(NameError.new("", cls)) else cls.is_a?(::Class) ? cls : cls.class end end |
+ (Settings) load!(*what)
Loads the extensions.
49 50 51 52 53 |
# File 'lib/lazier.rb', line 49 def self.load!(*what) (what.present? ? what : ["object", "boolean", "string", "hash", "datetime", "math", "pathname"]).each { |w| ::Lazier.send("load_#{w}") } yield if block_given? ::Lazier::Settings.instance end |
+ (Object) load_boolean
Loads Boolean extensions.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lazier.rb', line 61 def self.load_boolean ::TrueClass.class_eval do include ::Lazier::Object include ::Lazier::Boolean end ::FalseClass.class_eval do include ::Lazier::Object include ::Lazier::Boolean end end |
+ (Object) load_datetime
Loads DateTime extensions.
87 88 89 90 91 92 93 94 95 |
# File 'lib/lazier.rb', line 87 def self.load_datetime Lazier.load_object [::Time, ::Date, ::DateTime].each do |c| c.class_eval { include ::Lazier::DateTime } end ::ActiveSupport::TimeZone.class_eval { include ::Lazier::TimeZone } end |
+ (Object) load_hash
Loads Hash extensions.
79 80 81 82 83 84 |
# File 'lib/lazier.rb', line 79 def self.load_hash ::Hash.class_eval do include Hashie::Extensions::MethodAccess include ::Lazier::Hash end end |
+ (Object) load_math
Loads Math extensions.
98 99 100 101 |
# File 'lib/lazier.rb', line 98 def self.load_math Lazier.load_object ::Math.class_eval { include ::Lazier::Math } end |
+ (Object) load_object
Loads Object extensions.
56 57 58 |
# File 'lib/lazier.rb', line 56 def self.load_object ::Object.class_eval { include ::Lazier::Object } end |
+ (Object) load_pathname
Loads Pathname extensions.
104 105 106 107 |
# File 'lib/lazier.rb', line 104 def self.load_pathname require "pathname" ::Pathname.class_eval { include ::Lazier::Pathname } end |
+ (Object) load_string
Loads String extensions.
74 75 76 |
# File 'lib/lazier.rb', line 74 def self.load_string ::String.class_eval { include ::Lazier::String } end |
+ (Settings) settings
Returns the settings for the extensions.
33 34 35 |
# File 'lib/lazier.rb', line 33 def self.settings ::Lazier::Settings.instance end |