Sha256: 2b12e85f535ebf4f418655bb76763deeaa7a558b3d73465fc0fbc871d93dcec7

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

require_relative '../../dsl/intrinsic_functions'

module Convection
  module Model
    ##
    # Hash with auto-generating sparse keys
    ##
    class Smash < Hash
      def initialize(*args)
        super do |hash, key|
          hash[key] = Smash.new
        end
      end
    end

    class Template
      ##
      # Mapping
      ##
      class Mapping
        include DSL::IntrinsicFunctions

        attr_reader :items

        def initialize(name, template)
          @name = name
          @template = template

          @items = Smash.new
        end

        def item(key_1, key_2, value)
          items[key_1][key_2] = value
        end

        def render
          items
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convection-0.0.1 lib/convection/model/template/mapping.rb