Sha256: 7d225dcd17168d5410261d0becc440cbf3a23112f620b53744fb9d70998daddd

Contents?: true

Size: 501 Bytes

Versions: 20

Compression:

Stored size: 501 Bytes

Contents

require_relative "./util"
require "snake_camel/methods"

module Swagger
  class Schema
    module SchemaAccessor
      private

      def define_schema_accessor(*camel_names)
        camel_names.flatten.each do |name|
          define_method(name) { Util.try_hash(@schema, name) }

          alias_case name
        end
      end

      def alias_case(camel)
        snake = SnakeCamel::Methods.snakecase(camel.to_s)
        alias_method snake, camel unless snake == camel
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
swagger-serializer-0.9.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.9.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.8.3 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.8.2 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.8.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.8.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.7.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.6.2 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.6.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.6.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.5.2 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.5.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.5.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.4.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.4.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.3.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.2.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.2.0 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.1.1 lib/swagger/schema/schema_accessor.rb
swagger-serializer-0.1.0 lib/swagger/schema/schema_accessor.rb