Class: GrapeMarkdown::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-markdown/configuration.rb

Constant Summary collapse

SETTINGS =
[
  :name,
  :description,
  :request_headers,
  :response_headers,
  :example_id_type,
  :resource_exclusion,
  :include_root
]

Class Method Summary collapse

Class Method Details

.example_id_typeObject



50
51
52
# File 'lib/grape-markdown/configuration.rb', line 50

def example_id_type
  @example_id_type ||= :integer
end

.example_id_type=(value) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/grape-markdown/configuration.rb', line 40

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

.extend(setting) ⇒ Object



16
17
18
# File 'lib/grape-markdown/configuration.rb', line 16

def extend(setting)
  self.class.send :attr_accessor, setting
end

.generate_idObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/grape-markdown/configuration.rb', line 54

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

.include_rootObject



32
33
34
# File 'lib/grape-markdown/configuration.rb', line 32

def include_root
  @include_root ||= false
end

.request_headersObject



20
21
22
# File 'lib/grape-markdown/configuration.rb', line 20

def request_headers
  @request_headers ||= []
end

.resource_exclusionObject



28
29
30
# File 'lib/grape-markdown/configuration.rb', line 28

def resource_exclusion
  @resource_exclusion ||= []
end

.response_headersObject



24
25
26
# File 'lib/grape-markdown/configuration.rb', line 24

def response_headers
  @response_headers ||= []
end

.supported_id_typesObject



36
37
38
# File 'lib/grape-markdown/configuration.rb', line 36

def supported_id_types
  [:integer, :uuid, :bson]
end