Class: RedmineExtensions::EasyQueryPresenter::Outputs
- Inherits:
-
Object
- Object
- RedmineExtensions::EasyQueryPresenter::Outputs
show all
- Includes:
- Enumerable
- Defined in:
- app/presenters/redmine_extensions/easy_query_presenter.rb
Overview
—– OUTPUTS HELPER CLASS —-
Instance Method Summary
collapse
Constructor Details
#initialize(presenter) ⇒ Outputs
Returns a new instance of Outputs.
382
383
384
385
386
387
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 382
def initialize(presenter)
@presenter = presenter
@query = presenter.model
@query.outputs = ['table'] unless @query.outputs.any?
@outputs = @query.outputs.map{|o| RedmineExtensions::QueryOutput.output_klass_for(o).new(presenter) }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
413
414
415
416
417
418
419
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 413
def method_missing(name, *args)
if name.to_s.ends_with?('?')
output_enabled?(name.to_s[0..-2])
else
super
end
end
|
Instance Method Details
#available_output_instances ⇒ Object
#each(&block) ⇒ Object
389
390
391
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 389
def each(&block)
@outputs.each{|o| yield(o) }
end
|
#output_enabled?(output) ⇒ Boolean
401
402
403
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 401
def output_enabled?(output)
@query.outputs.include?(output.to_s)
end
|
#render_edit ⇒ Object
409
410
411
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 409
def render_edit
@outputs.map{ |output| output.render_edit }.join('').html_safe
end
|
#render_edit_selects(style = :check_box, options = {}) ⇒ Object
405
406
407
|
# File 'app/presenters/redmine_extensions/easy_query_presenter.rb', line 405
def render_edit_selects(style=:check_box, options={})
available_output_instances.map{|o| o.render_edit_box(style, options) }.join('').html_safe
end
|