Module: GrapeDSL::Extend::APIMNT
- Defined in:
- lib/grape-dsl/dsl.rb
Instance Method Summary collapse
-
#console_write_out_routes ⇒ Object
(also: #cw_routes)
write out to the console the class routes.
-
#description(opts = {}) ⇒ Object
defaults desc -> description for path body -> return body from the call convent_type -> real content type.
- #description=(obj) ⇒ Object
-
#mount_by(opts = {}) ⇒ Object
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
54 55 56 57 58 59 60 61 62 |
# File 'lib/grape-dsl/dsl.rb', line 54 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(opts = {}) ⇒ Object
defaults desc -> description for path body -> return body from the call convent_type -> real content type
11 12 13 14 15 16 17 18 19 |
# File 'lib/grape-dsl/dsl.rb', line 11 def description(opts={}) @last_description ||= {} unless @last_description[:description].class == Hashie::Mash @last_description[:description]= Hashie::Mash.new(opts.merge(desc: @last_description[:desc])) end return @last_description[:description] end |
#description=(obj) ⇒ Object
21 22 23 |
# File 'lib/grape-dsl/dsl.rb', line 21 def description= obj self.description.desc= obj end |
#mount_by(opts = {}) ⇒ Object
mount all the rest api classes that is subclass of the Grape::API make easy to manage
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/grape-dsl/dsl.rb', line 28 def mount_by opts= {} raise unless opts.class <= ::Hash opts[:class] ||= opts[:klass] || opts[:k] || opts[:c] || Grape::API 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 opts[:class].inherited_by.each do |component| mount(component) unless opts[:ex].include?(component) || self == component end opts[:in].each{ |klass| self.mount(klass) } return nil end |
#mount_subclasses(*exception) ⇒ Object Also known as: mount_classes
49 50 51 |
# File 'lib/grape-dsl/dsl.rb', line 49 def mount_subclasses(*exception) mount_by ex: exception end |