module RSpecApi::Resource::HasAttribute
Public Instance Methods
has_attribute(name, options, &block)
click to toggle source
# File lib/rspec-api/resource/has_attribute.rb, line 7 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 Instance Methods
nest_attributes(hash) { || ... }
click to toggle source
# File lib/rspec-api/resource/has_attribute.rb, line 22 def nest_attributes(hash, &block) (@attribute_ancestors ||= []).push hash yield @attribute_ancestors.pop end