Class: GlDateConfiguration

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/apl-library/gl_date_configuration.rb

Class Method Summary collapse

Class Method Details

.evaluate_conditions(rows, req_gl_date, obj_gl_date) ⇒ Object



14
15
16
17
18
# File 'lib/apl-library/gl_date_configuration.rb', line 14

def self.evaluate_conditions rows, req_gl_date, obj_gl_date
  rows.each do |row|
    return eval(row.result) if eval(row.condition)
  end
end

.get_gl_date(params) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/apl-library/gl_date_configuration.rb', line 5

def self.get_gl_date params
  context = params[:context]
  req_gl_date = params[:req_gl_date]
  obj_gl_date = params[:obj_gl_date]
  rows = GlDateConfiguration.where(:context => context)
  return nil if rows.blank?
  return evaluate_conditions rows, req_gl_date, obj_gl_date
end