Sha256: 3118fe11354a08473584f38c9b57d04632a9ecb6eb1b1f2bf6c4e2262c4732da
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
module GrapeMarkdown class Configuration SETTINGS = [ :name, :description, :request_headers, :response_headers, :example_id_type, :resource_exclusion, :include_root ] class << self attr_accessor(*SETTINGS) def extend(setting) self.class.send :attr_accessor, setting end def request_headers @request_headers ||= [] end def response_headers @response_headers ||= [] end def resource_exclusion @resource_exclusion ||= [] end def include_root @include_root ||= false end def supported_id_types [:integer, :uuid, :bson] end def example_id_type=(value) fail UnsupportedIDType unless supported_id_types.include?(value) if value.to_sym == :bson && !Object.const_defined?('BSON') fail BSONNotDefinied end @example_id_type = value end def example_id_type @example_id_type ||= :integer end def generate_id case example_id_type when :integer SecureRandom.random_number(1000) when :uuid SecureRandom.uuid when :bson BSON::ObjectId.new.to_s end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems