Sha256: 98a84ae80bab519d180c3982edaa492decd8ae8269865e37d3f78830f9250000
Contents?: true
Size: 759 Bytes
Versions: 2
Compression:
Stored size: 759 Bytes
Contents
require 'active_support/core_ext/object/blank' require 'rspec-api/resource/options' module RSpecApi module Resource module HasAttribute def has_attribute(name, options, &block) if block_given? options[:type] = Hash[options[:type], {}] nest_attributes options[:type], &Proc.new end if @attribute_ancestors.present? hash = @attribute_ancestors.last hash.each{|type, _| (hash[type] ||= {})[name] = options} else (rspec_api_resource[:attributes] ||= {})[name] = options end end private def nest_attributes(hash, &block) (@attribute_ancestors ||= []).push hash yield @attribute_ancestors.pop end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-api-0.7.1 | lib/rspec-api/resource/has_attribute.rb |
rspec-api-0.7.0 | lib/rspec-api/resource/has_attribute.rb |