Sha256: d3cc3756f402119084edb36e56cbfd771cf3bf97fe16230b8067d6d0d7a089da

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

module Eco
  module Common
    class MetaThor
      class Value
        KEY = "MetaThorValue"
        KEY_OPTION = "MetaThorJSON"

        class << self
          def to_value(doc)
            case
            when doc.is_a?(Hash)
              case
              when doc.key?(KEY_OPTION)
                to_value(doc[KEY_OPTION])
              when doc.key?(KEY)
                doc[KEY]
              else
                doc
              end
            when doc.is_a?(String)
              to_value(JSON.parse(doc))
            when doc.is_a?(Value)
              value.value
            end
          end

          def key?(object)

          end
        end

        attr_reader :value

        def initialize(value)
          @doc = {"#{KEY}" => value}
        end

        def value
          @doc[KEY]
        end

        def as_input_option
          "--#{INPUT_OPTION}=#{KEY_OPTION}:#{@doc.to_json}"
        end

        def as_option
          {"#{INPUT_SYM}" => self}
        end

      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eco-helpers-0.8.3 lib/eco/common/meta_thor/value.rb
eco-helpers-0.8.2 lib/eco/common/meta_thor/value.rb
eco-helpers-0.8.1 lib/eco/common/meta_thor/value.rb
eco-helpers-0.7.2 lib/eco/common/meta_thor/value.rb
eco-helpers-0.7.1 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.17 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.16 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.15 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.13 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.12 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.11 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.9 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.8 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.7 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.6 lib/eco/common/meta_thor/value.rb
eco-helpers-0.6.5 lib/eco/common/meta_thor/value.rb