Sha256: e32b7db7d29249ad21f3bfa371fe6ab7697a5c916cfc66efd723c65883a7e326

Contents?: true

Size: 668 Bytes

Versions: 119

Compression:

Stored size: 668 Bytes

Contents

class Promethee::Data
  def initialize(data)
    @data = hashify data
  end

  def data
    @data
  end

  # The class creates a facade in front of the real hash, therefore include?, [] and to_json are delegated
  def include?(value)
    @data.include? value
  end

  def [](value)
    @data[value]
  end

  def to_json
    @data.to_json
  end

  protected

  def hashify(data)
    # https://github.com/bbatsov/ruby-style-guide#indent-conditional-assignment
    h = case data.class.to_s
        when 'Hash', 'ActiveSupport::HashWithIndifferentAccess' then data
        when 'String' then JSON.parse data
        else {}
        end
    h.deep_symbolize_keys
  end
end

Version data entries

119 entries across 119 versions & 1 rubygems

Version Path
promethee-5.1.1 lib/promethee/data.rb
promethee-5.1.0 lib/promethee/data.rb
promethee-5.0.2 lib/promethee/data.rb
promethee-5.0.1 lib/promethee/data.rb
promethee-5.0.0 lib/promethee/data.rb
promethee-4.1.28 lib/promethee/data.rb
promethee-4.1.27 lib/promethee/data.rb
promethee-4.1.26 lib/promethee/data.rb
promethee-4.1.25 lib/promethee/data.rb
promethee-4.1.24 lib/promethee/data.rb
promethee-4.1.23 lib/promethee/data.rb
promethee-4.1.22 lib/promethee/data.rb
promethee-4.1.21 lib/promethee/data.rb
promethee-4.1.20 lib/promethee/data.rb
promethee-4.1.19 lib/promethee/data.rb
promethee-4.1.18 lib/promethee/data.rb
promethee-4.1.17 lib/promethee/data.rb
promethee-4.1.16 lib/promethee/data.rb
promethee-4.1.15 lib/promethee/data.rb
promethee-4.1.14 lib/promethee/data.rb