Module: Rested

Defined in:
lib/rested/base.rb,
lib/rested/debug.rb,
lib/rested/error.rb,
lib/rested/entity.rb,
lib/rested/validations.rb

Defined Under Namespace

Modules: BaseMethods Classes: Base, Entity, Error, ObjectNotFound, Validations

Class Method Summary collapse

Class Method Details

.debug(val = nil) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/rested/debug.rb', line 5

def self.debug(val=nil)
    return @debug if val.nil?
    if val == true || val == 1 || val.nil? then
        @debug = STDOUT
    else
        @debug = val
    end
end

.debug=(val) ⇒ Object



14
15
16
# File 'lib/rested/debug.rb', line 14

def self.debug=(val)
    self.debug(val)
end

.log(msg = nil, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rested/debug.rb', line 18

def self.log(msg = nil, &block)
    return unless @debug
    if block_given? then
        s = yield
        return if not s.kind_of? String
        msg = s
    end
    return if msg.nil?
    if @debug.respond_to? :puts then
        @debug.puts(msg)
    elsif @debug.respond_to? :debug then
        @debug.debug(msg)
    else
        puts "[Rested.debug] #{msg}"
    end
end

.log_do(msg = nil, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/rested/debug.rb', line 35

def self.log_do(msg = nil, &block)
    if block_given? then
        s = yield
        return if not s.kind_of? String
        log { "* " + s }
    else
        log("* #{msg}")
    end
end

.log_in(msg = nil, &block) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/rested/debug.rb', line 45

def self.(msg = nil, &block)
    if block_given? then
        s = yield
        return if not s.kind_of? String
        log { "< " + s }
    else
        log("< #{msg}")
    end
end

.log_out(msg = nil, &block) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/rested/debug.rb', line 55

def self.log_out(msg = nil, &block)
    if block_given? then
        s = yield
        return if not s.kind_of? String
        log { "> " + s }
    else
        log("> #{msg}")
    end
end