Module: Lazier

Defined in:
lib/lazier.rb,
lib/lazier/hash.rb,
lib/lazier/i18n.rb,
lib/lazier/math.rb,
lib/lazier/object.rb,
lib/lazier/string.rb,
lib/lazier/boolean.rb,
lib/lazier/version.rb,
lib/lazier/datetime.rb,
lib/lazier/pathname.rb,
lib/lazier/settings.rb,
lib/lazier/exceptions.rb

Overview

This file is part of the lazier gem. Copyright (C) 2013 and above Shogun . 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: Settings

Class Method Summary collapse

Class Method Details

.load!(*what) ⇒ Settings

Loads the extensions.

Parameters:

  • what (Array)

    The modules to load. Valid values are:

    @option object Extensions for all objects. @option boolean Extensions for boolean values. @option string Extensions for strings. @option hash Extensions for hashs. @option datetime Extensions date and time objects. @option math Extensions for Math module. @option pathname Extensions for path objects.

Returns:

  • (Settings)

    The settings for the extensions.



46
47
48
49
50
51
52
# File 'lib/lazier.rb', line 46

def self.load!(*what)
  what = ["object", "boolean", "string", "hash", "datetime", "math", "pathname"] if what.count == 0
  what.collect! { |w| ::Lazier.send("load_#{w}") }

  yield if block_given?
  ::Lazier::Settings.instance
end

.load_booleanObject

Loads Boolean extensions.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/lazier.rb', line 62

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

.load_datetimeObject

Loads DateTime extensions.



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/lazier.rb', line 89

def self.load_datetime
  Lazier.load_object

  [::Time, ::Date, ::DateTime].each do |c|
    c.class_eval do
      include ::Lazier::DateTime
    end
  end

  ::ActiveSupport::TimeZone.class_eval do
    include ::Lazier::TimeZone
  end
end

.load_hashObject

Loads Hash extensions.



82
83
84
85
86
# File 'lib/lazier.rb', line 82

def self.load_hash
  ::Hash.class_eval do
    include ::Lazier::Hash
  end
end

.load_mathObject

Loads Math extensions.



104
105
106
107
108
109
110
# File 'lib/lazier.rb', line 104

def self.load_math
  Lazier.load_object

  ::Math.class_eval do
    include ::Lazier::Math
  end
end

.load_objectObject

Loads Object extensions.



55
56
57
58
59
# File 'lib/lazier.rb', line 55

def self.load_object
  ::Object.class_eval do
    include ::Lazier::Object
  end
end

.load_pathnameObject

Loads Pathname extensions.



113
114
115
116
117
118
119
# File 'lib/lazier.rb', line 113

def self.load_pathname
  require "pathname"

  ::Pathname.class_eval do
    include ::Lazier::Pathname
  end
end

.load_stringObject

Loads String extensions.



75
76
77
78
79
# File 'lib/lazier.rb', line 75

def self.load_string
  ::String.class_eval do
    include ::Lazier::String
  end
end

.settingsSettings

Returns the settings for the extensions.

Returns:

  • (Settings)

    The settings for the extensions.



30
31
32
# File 'lib/lazier.rb', line 30

def self.settings
  ::Lazier::Settings.instance
end