Module: GtfsEngine::Concerns::Controllers::Gtfs
- Extended by:
- ActiveSupport::Concern
- Included in:
- AgenciesController, GtfsEngine::CalendarDatesController, GtfsEngine::CalendarsController, FareAttributesController, FareRulesController, FeedInfosController, FrequenciesController, RoutesController, ShapesController, StopTimesController, StopsController, TransfersController, TripsController
- Defined in:
- lib/gtfs_engine/concerns/controllers/gtfs.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#filter ⇒ ActionController::Parameters
derived from the query string.
-
#index ⇒ Object
GET / collection of elements for the given GTFS type The returned collection may be filtered with query parameters.
-
#show ⇒ Object
GET /:id for a specific element of the given GTFS type.
Instance Method Details
#filter ⇒ ActionController::Parameters
derived from the query string
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gtfs_engine/concerns/controllers/gtfs.rb', line 52 def filter @filter ||= begin query = self.query unknown = query.map do |q, v| query[q] = true if v.blank? # blank value indicates boolean filter filters.include?(q.to_sym) ? nil : q end.compact unless unknown.empty? raise GtfsEngine::UnknownFilters.new(unknown), 'unknown filter' end query_params = ActionController::Parameters.new query query_params.permit filters end end |
#index ⇒ Object
GET / collection of elements for the given GTFS type The returned collection may be filtered with query parameters
39 40 41 42 |
# File 'lib/gtfs_engine/concerns/controllers/gtfs.rb', line 39 def index @records = query.empty? ? collection : filtered_collection respond_with @records, template: 'gtfs_engine/gtfs/index' end |
#show ⇒ Object
GET /:id for a specific element of the given GTFS type
45 46 47 48 |
# File 'lib/gtfs_engine/concerns/controllers/gtfs.rb', line 45 def show @record = record respond_with @record, template: 'gtfs_engine/gtfs/show' end |