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-1.1.3 lib/convection/model/mixin/colorize.rb
convection-1.1.2 lib/convection/model/mixin/colorize.rb
convection-1.1.1 lib/convection/model/mixin/colorize.rb
convection-1.1.0 lib/convection/model/mixin/colorize.rb
convection-1.0.7 lib/convection/model/mixin/colorize.rb
convection-1.0.6 lib/convection/model/mixin/colorize.rb
convection-1.0.5 lib/convection/model/mixin/colorize.rb
convection-1.0.4 lib/convection/model/mixin/colorize.rb
convection-1.0.3 lib/convection/model/mixin/colorize.rb
convection-1.0.2 lib/convection/model/mixin/colorize.rb
convection-1.0.1 lib/convection/model/mixin/colorize.rb
convection-1.0.0.pre.beta.10 lib/convection/model/mixin/colorize.rb
convection-1.0.0.pre.beta.9 lib/convection/model/mixin/colorize.rb
convection-1.0.0.pre.beta.8 lib/convection/model/mixin/colorize.rb