lib/grape-markdown/parameter.rb in grape-markdown-0.0.6 vs lib/grape-markdown/parameter.rb in grape-markdown-0.0.7
- old
+ new
@@ -1,10 +1,10 @@
module GrapeMarkdown
class Parameter
attr_reader :route, :full_name, :name, :settings
- delegate :route_name, :route_namespace, to: :route
+ delegate :route_name, :namespace, to: :route
delegate :requirement, :type, :documentation, :desc, to: :settings
delegate :example, to: :documentation, allow_nil: true
def initialize(route, name, options)
@full_name = name
@@ -23,23 +23,21 @@
def parse_options(options)
options = default_options(options) if options.blank?
options[:requirement] = options[:required] ? 'required' : 'optional'
- Hashie::Mash.new(options)
+ JSON.parse(options.to_json, object_class: OpenStruct)
end
- def default_options(options)
+ def default_options(_options)
model = name.include?('_id') ? name.gsub('_id', '') : route.route_name
{
- required: true,
- requirement: 'required',
- type: 'uuid',
- desc: "the `id` of the `#{model}`",
- documentation: {
- example: GrapeMarkdown::Configuration.generate_id
- }
+ required: true,
+ requirement: 'required',
+ type: 'uuid',
+ desc: "the `id` of the `#{model}`",
+ documentation: { example: GrapeMarkdown::Configuration.generate_id }
}
end
end
end