Class: ForemanStatistics::Api::V2::TrendsController
- Inherits:
-
Api::V2::BaseController
- Object
- Api::V2::BaseController
- ForemanStatistics::Api::V2::TrendsController
- Includes:
- Parameters::Trend
- Defined in:
- app/controllers/foreman_statistics/api/v2/trends_controller.rb
Constant Summary collapse
- TRENDABLE_TYPES =
%w[ Environment Operatingsystem Model FactName Hostgroup ComputeResource ].freeze
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #resource_scope(options = {}) ⇒ Object
-
#resource_scope_for_index(options = {}) ⇒ Object
Overload this method to avoid using search_for method.
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 32 def create @trend = ForemanStatistics::Trend.build_trend(trend_params) if @trend.save process_success else process_resource_error end end |
#destroy ⇒ Object
43 44 45 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 43 def destroy process_response @trend.destroy end |
#index ⇒ Object
20 21 22 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 20 def index @trends = resource_scope_for_index end |
#resource_scope(options = {}) ⇒ Object
52 53 54 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 52 def resource_scope( = {}) @resource_scope ||= scope_for(ForemanStatistics::Trend.types, ) end |
#resource_scope_for_index(options = {}) ⇒ Object
Overload this method to avoid using search_for method
48 49 50 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 48 def resource_scope_for_index( = {}) resource_scope().paginate() end |
#show ⇒ Object
26 |
# File 'app/controllers/foreman_statistics/api/v2/trends_controller.rb', line 26 def show; end |