Familia::Status

Public Class Methods

included(obj) click to toggle source
# File lib/familia/helpers.rb, line 44
def self.included(obj)
  obj.module_eval do
    field :status
    field :message
    def  failure?()        status? 'failure'       end
    def  success?()        status? 'success'       end
    def  pending?()        status? 'pending'       end
    def  expired?()        status? 'expired'       end
    def disabled?()        status? 'disabled'      end
    def  failure!(msg=nil) status! 'failure',  msg end
    def  success!(msg=nil) status! 'success',  msg end
    def  pending!(msg=nil) status! 'pending',  msg end
    def  expired!(msg=nil) status! 'expired',  msg end
    def disabled!(msg=nil) status! 'disabled', msg end
    private
    def status?(s)
      status.to_s == s.to_s
    end
    def status!(s, msg=nil)
      @updated = Time.now.utc.to_f
      @status, @message = s, msg
      save if respond_to? :save
    end
  end
end

Public Instance Methods

disabled!(msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 57
def disabled!(msg=nil) status! 'disabled', msg end
disabled?() click to toggle source
# File lib/familia/helpers.rb, line 52
def disabled?()        status? 'disabled'      end
expired!(msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 56
def  expired!(msg=nil) status! 'expired',  msg end
expired?() click to toggle source
# File lib/familia/helpers.rb, line 51
def  expired?()        status? 'expired'       end
failure!(msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 53
def  failure!(msg=nil) status! 'failure',  msg end
failure?() click to toggle source
# File lib/familia/helpers.rb, line 48
def  failure?()        status? 'failure'       end
pending!(msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 55
def  pending!(msg=nil) status! 'pending',  msg end
pending?() click to toggle source
# File lib/familia/helpers.rb, line 50
def  pending?()        status? 'pending'       end
status!(s, msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 62
def status!(s, msg=nil)
  @updated = Time.now.utc.to_f
  @status, @message = s, msg
  save if respond_to? :save
end
status?(s) click to toggle source
# File lib/familia/helpers.rb, line 59
def status?(s)
  status.to_s == s.to_s
end
success!(msg=nil) click to toggle source
# File lib/familia/helpers.rb, line 54
def  success!(msg=nil) status! 'success',  msg end
success?() click to toggle source
# File lib/familia/helpers.rb, line 49
def  success?()        status? 'success'       end

[Validate]

Generated with the Darkfish Rdoc Generator 2.