Sha256: 8355f823b340b68c38280d9098abc110cc873f8eb5cfe4056d816e0232c73bf6

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

require 'sham/nested'

module Sham
  class Config
    class Base
      def object(klass)
        @klass = klass

        self
      end

      def sham(build = false)
        if build || !@klass.respond_to?(:create)
          @klass.new(*args)
        else
          @klass.create(*args)
        end
      end

      private

      def parse! value
        if value.is_a?(Array)
          value.map{ |k| parse!(k) }
        elsif value.is_a?(Hash)
          Hash.new value.map{ |k,v| [k, parse!(v)] }
        elsif value.is_a?(Sham::Nested)
          value.sham!
        else
          value
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sham-1.1.0 lib/sham/config/base.rb
sham-1.0.3 lib/sham/config/base.rb