Module: Lazier

Defined in:
lib/lazier.rb,
lib/lazier/math.rb,
lib/lazier/hash.rb,
lib/lazier/string.rb,
lib/lazier/object.rb,
lib/lazier/boolean.rb,
lib/lazier/version.rb,
lib/lazier/pathname.rb,
lib/lazier/settings.rb,
lib/lazier/datetime.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, Math, Object, Pathname, String, TimeZone, Version Classes: Settings

Class Method Summary (collapse)

Class Method Details

+ (Settings) load!(*what)

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.



43
44
45
46
47
48
49
# File 'lib/lazier.rb', line 43

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

+ (Object) load_boolean

Loads Boolean extensions.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/lazier.rb', line 59

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.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/lazier.rb', line 86

def self.load_datetime
  Lazier.load_object

  ::Time.class_eval do
    include ::Lazier::DateTime
  end

  ::Date.class_eval do
    include ::Lazier::DateTime
  end

  ::DateTime.class_eval do
    include ::Lazier::DateTime
  end

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

+ (Object) load_hash

Loads Hash extensions.



79
80
81
82
83
# File 'lib/lazier.rb', line 79

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

+ (Object) load_math

Loads Math extensions.



107
108
109
110
111
112
113
# File 'lib/lazier.rb', line 107

def self.load_math
  Lazier.load_object

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

+ (Object) load_object

Loads Object extensions.



52
53
54
55
56
# File 'lib/lazier.rb', line 52

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

+ (Object) load_pathname

Loads Pathname extensions.



116
117
118
119
120
121
122
# File 'lib/lazier.rb', line 116

def self.load_pathname
  require "pathname"

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

+ (Object) load_string

Loads String extensions.



72
73
74
75
76
# File 'lib/lazier.rb', line 72

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

+ (Settings) settings

Returns the settings for the extensions

Returns:

  • (Settings)

    The settings for the extensions.



28
29
30
# File 'lib/lazier.rb', line 28

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