class Aws::Stubbing::EmptyStub
Public Class Methods
Source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 10 def initialize(rules) @rules = rules end
@param [Seahorse::Models::Shapes::ShapeRef] rules
Public Instance Methods
Source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 15 def stub if @rules stub_ref(@rules) else EmptyStructure.new end end
@return [Structure]
Private Instance Methods
Source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 25 def stub_ref(ref, visited = []) if visited.include?(ref.shape) return nil else visited = visited + [ref.shape] end case ref.shape when StructureShape then stub_structure(ref, visited) when ListShape then [] when MapShape then {} else stub_scalar(ref) end end
Source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 49 def stub_scalar(ref) case ref.shape when StringShape then ref.shape.name || 'string' when IntegerShape then 0 when FloatShape then 0.0 when BooleanShape then false when TimestampShape then Time.now else nil end end
Source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 39 def stub_structure(ref, visited) ref.shape.members.inject(ref.shape.struct_class.new) do |struct, (mname, mref)| # For eventstream shape, it returns an Enumerator unless mref.eventstream struct[mname] = stub_ref(mref, visited) end struct end end