Sha256: 5604960c9626420c1e93cea12c3c5e5dfe9cf22b1268f65fa1774c819f91ad9e

Contents?: true

Size: 659 Bytes

Versions: 2

Compression:

Stored size: 659 Bytes

Contents

require 'ostruct'

class Frenetic
  module ResourceMockery

    def attributes
      @params
    end

    def properties
      @params.each_with_object({}) do |(k,v), props|
        props[k] = v.class.to_s.underscore
      end
    end

    # Provides a place for a Resources that are mocked to declare reasonable
    # default values for Mock Resources
    def default_attributes
      {}
    end

  private

    def build_params( p )
      defaults = default_attributes.with_indifferent_access
      @params  = defaults.merge( (p || {}).with_indifferent_access )
    end

    def build_structure
      @structure = OpenStruct.new( @attrs )
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frenetic-0.0.20.alpha.4 lib/frenetic/concerns/resource_mockery.rb
frenetic-0.0.20.alpha.3 lib/frenetic/concerns/resource_mockery.rb