class Aws::Stubbing::EmptyStub
Public Class Methods
new(rules)
click to toggle source
@param [Seahorse::Models::Shapes::ShapeRef] rules
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 8 def initialize(rules) @rules = rules end
Public Instance Methods
stub()
click to toggle source
@return [Structure]
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 13 def stub stub_ref(@rules) end
Private Instance Methods
stub_ref(ref, visited = [])
click to toggle source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 19 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
stub_scalar(ref)
click to toggle source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 40 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
stub_structure(ref, visited)
click to toggle source
# File lib/aws-sdk-core/stubbing/empty_stub.rb, line 33 def stub_structure(ref, visited) ref.shape.members.inject(ref[:struct_class].new) do |struct, (mname, mref)| struct[mname] = stub_ref(mref, visited) struct end end