Sha256: 086a64abaf4413606f838c394dad68e893a4e36b49a27c102225d66374403fec

Contents?: true

Size: 689 Bytes

Versions: 54

Compression:

Stored size: 689 Bytes

Contents

module Convection
  module Model
    module Mixin
      module Colorize
        def colorize(param, options = {})
          define_method(:color) do
            case instance_variable_get("@#{ param }")
            when *options.fetch(:white, [:status]) then :white
            when *options.fetch(:cyan, [:debug, :trace]) then :cyan
            when *options.fetch(:green, [:info, :success, :create]) then :green
            when *options.fetch(:yellow, [:warn, :update]) then :yellow
            when *options.fetch(:red, [:error, :fail, :delete, :replace]) then :red
            else options.fetch(:default, :green)
            end
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
convection-2.2.12 lib/convection/model/mixin/colorize.rb
convection-2.2.11 lib/convection/model/mixin/colorize.rb
convection-2.2.10 lib/convection/model/mixin/colorize.rb
convection-2.2.9 lib/convection/model/mixin/colorize.rb
convection-2.2.8 lib/convection/model/mixin/colorize.rb
convection-2.2.7 lib/convection/model/mixin/colorize.rb
convection-2.2.6 lib/convection/model/mixin/colorize.rb
convection-2.2.5 lib/convection/model/mixin/colorize.rb
convection-2.2.4 lib/convection/model/mixin/colorize.rb
convection-2.2.3 lib/convection/model/mixin/colorize.rb
convection-2.2.2 lib/convection/model/mixin/colorize.rb
convection-2.2.1 lib/convection/model/mixin/colorize.rb
convection-2.2.0 lib/convection/model/mixin/colorize.rb
convection-2.1.2 lib/convection/model/mixin/colorize.rb
convection-2.1.1 lib/convection/model/mixin/colorize.rb
convection-2.1.0 lib/convection/model/mixin/colorize.rb
convection-2.0.0 lib/convection/model/mixin/colorize.rb
convection-1.1.7 lib/convection/model/mixin/colorize.rb
convection-1.1.5 lib/convection/model/mixin/colorize.rb
convection-1.1.4 lib/convection/model/mixin/colorize.rb