Module: Extensions::Object

Defined in:
lib/baltix/extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.const_get(c, inherit = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/baltix/extensions.rb', line 3

def self.const_get c, inherit = true
   super
rescue Exception => e
   begin
     require c.to_s.downcase
   rescue Exception => e
   end

   super
end

Instance Method Details

#blank?Boolean



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/baltix/extensions.rb', line 14

def blank?
   case self
   when ::NilClass, ::FalseClass
      true
   when ::TrueClass
      false
   when ::Hash, ::Array
      !self.any?
   else
      self.to_s == ""
   end
end

#to_os(hash: false, array: false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/baltix/extensions.rb', line 27

def to_os hash: false, array: false
   value =
     self.to_h.map do |(x, y_in)|
        y =
           if hash && y_in.is_a?(Hash) || array && y_in.is_a?(Array)
              y_in.to_os(hash: hash, array: array)
           else
              y_in
           end

        [x.to_s, y]
      end.to_h

   ::OpenStruct.new(value)
end