Sha256: 931841b3766460389402cfcb83afbe99ae843fbc9f5f6abbc8166fd40acca575

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 Bytes

Contents

class GlDateConfiguration < ActiveRecord::Base

  attr_accessible :id, :context, :condition, :result

  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

  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
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
apl-library-0.0.90 lib/apl-library/gl_date_configuration.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/lib/apl-library/gl_date_configuration.rb