Module: GrapeDSL::Extend::APIMNT
- Defined in:
- lib/grape-dsl/dsl.rb
Defined Under Namespace
Classes: Description
Instance Method Summary collapse
-
#console_write_out_routes ⇒ Object
(also: #cw_routes)
write out to the console the class routes.
-
#description(*args) ⇒ Object
defaults desc -> description for path body -> return body from the call convent_type -> real content type.
-
#mount_api(opts = {}) ⇒ Object
(also: #mount_apis)
mount all the rest api classes that is subclass of the Grape::API make easy to manage.
- #mount_subclasses(*exception) ⇒ Object (also: #mount_classes)
Instance Method Details
#console_write_out_routes ⇒ Object Also known as: cw_routes
write out to the console the class routes
103 104 105 106 107 108 109 110 111 |
# File 'lib/grape-dsl/dsl.rb', line 103 def console_write_out_routes $stdout.puts "\n\nREST::API ROUTES:" self.routes.each do |route| $stdout.puts "#{route.route_method}","\t#{route.route_path}\n---\n" end return nil end |
#description(*args) ⇒ Object
defaults desc -> description for path body -> return body from the call convent_type -> real content type
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/grape-dsl/dsl.rb', line 38 def description(*args) if desc.class != ::GrapeDSL::Extend::APIMNT::Description var= ::GrapeDSL::Extend::APIMNT::Description.new(*args) unless self.content_types.keys.empty? content_type_name= nil [:json,:xml,:txt].each do |element| if self.content_types.keys.include? element content_type_name ||= element.to_s.upcase end end var.content_type= content_type_name end var.desc= desc.to_s desc var end return desc end |
#mount_api(opts = {}) ⇒ Object Also known as: mount_apis
mount all the rest api classes that is subclass of the Grape::API make easy to manage
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/grape-dsl/dsl.rb', line 68 def mount_api opts= {} unless opts.class <= Hash raise ArgumentError,"invalid option object given, must be hash like!" end opts[:ex] ||= opts[:except] || opts[:exception] || opts[:e] || [] opts[:in] ||= opts[:include] || opts[:inclusion] || opts[:i] || [] [:ex,:in].each{|sym| (opts[sym]=[opts[sym]]) unless opts[sym].class <= Array } # mount components Grape::API.inherited_by.each do |component| unless opts[:ex].include?(component) || self == component mount(component) end end opts[:in].each{|cls| self.mount(cls) } return nil end |
#mount_subclasses(*exception) ⇒ Object Also known as: mount_classes
96 97 98 |
# File 'lib/grape-dsl/dsl.rb', line 96 def mount_subclasses(*exception) mount_api ex: exception end |