Sha256: 902639be6ed4465fc309d17570743d1e0873cdf55581b953bf2618b060e9eb25

Contents?: true

Size: 400 Bytes

Versions: 9

Compression:

Stored size: 400 Bytes

Contents

require "ostruct"

module Ucasy
  class Context < OpenStruct
    def self.build(context = {})
      (self === context) ? context : new(context)
    end

    def fail!(options = {})
      options.each { |key, value| self[key.to_sym] = value }
      @failure = true
      raise Failure, self
    end

    def failure?
      @failure || false
    end

    def success?
      !failure?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ucasy-0.2.1 lib/ucasy/context.rb
ucasy-0.2.0 lib/ucasy/context.rb
ucasy-0.1.0 lib/ucasy/context.rb
ucasy-0.0.7 lib/ucasy/context.rb
ucasy-0.0.6 lib/ucasy/context.rb
ucasy-0.0.5 lib/ucasy/context.rb
ucasy-0.0.4 lib/ucasy/context.rb
ucasy-0.0.3 lib/ucasy/context.rb
ucasy-0.0.1 lib/ucasy/context.rb