Sha256: e6b8f0a40ee29f329bd712806f1dd3012723d6f36ce45ba315701e2e1556d891
Contents?: true
Size: 962 Bytes
Versions: 2
Compression:
Stored size: 962 Bytes
Contents
module Commute # Public: A Generic status object that can represent # either a positive or negative status. # # When the status is negative, an additional error # detail can be provided. # # Examples # # Status.new false, { reason: 'No access' } # Status.ok # Same as Status.new true # class Status # Public: Creates a positive status. # def self.ok self.new end # Public: Creates a new status object. # # success - Whether the status is positive or not (default: true). # error - Optional error detail (can be anything). # def initialize success = true, error = nil @success = success end # Public: Check if a status is a success. # # Returns true if the status is positive. def success? @success end # Public: Check if a status is a fail. # # Returns true if the status is negative. def fail? !success? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
commute-0.3.0.pre.2 | lib/commute/core/status.rb |
commute-0.3.0.pre | lib/commute/core/status.rb |