Sha256: 0c12ba2186925e1441e66e29e3eb0dbc84245166d3df201f9062332af7f331d3
Contents?: true
Size: 1.43 KB
Versions: 13
Compression:
Stored size: 1.43 KB
Contents
module Logical module Naf class Application attr_reader :app include ActionView::Helpers::TextHelper COLUMNS = [:id, :title, :short_name, :script_type_name, :application_schedules, :deleted] FILTER_FIELDS = [:deleted] SEARCH_FIELDS = [:title, :command, :short_name] def initialize(naf_app) @app = naf_app end def self.search(search) application_scope = ::Naf::Application.order("id desc") FILTER_FIELDS.each do |field| if search.present? and search[field].present? application_scope = application_scope.where(field => search[field]) end end SEARCH_FIELDS.each do |field| if search.present? and search[field].present? application_scope = application_scope.where(["lower(#{field}) ~ ?", Regexp.escape(search[field].downcase)]) end end application_scope.map{ |physical_app| new(physical_app) } end def to_hash Hash[ COLUMNS.map{ |m| [m, send(m)] } ] end def command @app.command end def method_missing(method_name, *arguments, &block) if @app.respond_to?(method_name) @app.send(method_name, *arguments, &block) else super end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems