Sha256: 7dcda44ceef6514634a368012c5206897b72be4ea1b91abc6447650ba86e1a69

Contents?: true

Size: 504 Bytes

Versions: 304

Compression:

Stored size: 504 Bytes

Contents

module Gherkin
  module Formatter
    class Hashable
      def to_hash
        instance_variables.inject({}) do |hash, ivar|
          value = instance_variable_get(ivar)
          value = value.to_hash if value.respond_to?(:to_hash)
          if Array === value
            value = value.map do |e|
              e.respond_to?(:to_hash) ? e.to_hash : e
            end
          end
          hash[ivar[1..-1]] = value unless [[], nil].index(value)
          hash
        end
      end
    end
  end
end

Version data entries

304 entries across 299 versions & 9 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/gherkin-2.11.1/lib/gherkin/formatter/hashable.rb
candlepin-api-0.4.0 bundle/ruby/gems/gherkin-2.11.1/lib/gherkin/formatter/hashable.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/gherkin-2.11.1/lib/gherkin/formatter/hashable.rb
gherkin-2.11.5 lib/gherkin/formatter/hashable.rb
gherkin-2.11.5-x86-mswin32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.5-x86-mingw32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.5-java lib/gherkin/formatter/hashable.rb
gherkin-2.11.4 lib/gherkin/formatter/hashable.rb
gherkin-2.11.4-x86-mswin32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.4-x86-mingw32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.4-java lib/gherkin/formatter/hashable.rb
gherkin-2.11.3 lib/gherkin/formatter/hashable.rb
gherkin-2.11.3-x86-mswin32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.3-x86-mingw32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.3-java lib/gherkin/formatter/hashable.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/gherkin-2.11.1/lib/gherkin/formatter/hashable.rb
gherkin-2.11.2 lib/gherkin/formatter/hashable.rb
gherkin-2.11.2-x86-mswin32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.2-x86-mingw32 lib/gherkin/formatter/hashable.rb
gherkin-2.11.2-java lib/gherkin/formatter/hashable.rb