Sha256: 1e3200859e60d5e61d2069b18d1cbd787b92e02c039e67cde976edde2741472d

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

module AppManifest
  # A simple model-like wrapper around a manifest hash.
  class Manifest
    include Virtus.model
    include EnvironmentAttributes
    include Serializer

    attribute :environments, Hash[String => Environment], default: nil

    def self.from_json(string)
      hash = MultiJson.load(string)
      new(hash)
    end

    def initialize(hash)
      canonicalized = AppManifest.canonicalize(hash)
      super(canonicalized)
    end

    def environment(name)
      scoped_data = (environments || {}).fetch(name.to_s, {}).to_hash
      global_data = to_hash
      Environment.new(global_data.merge(scoped_data))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
app_manifest-0.4.0 lib/app_manifest/manifest.rb
app_manifest-0.3.0 lib/app_manifest/manifest.rb