class PeoplesoftModels::Record

Public Class Methods

table_name() click to toggle source
# File lib/peoplesoft_models/record.rb, line 11
def self.table_name
  [self.schema_name, "PSRECDEFN"].compact.join(".")
end

Public Instance Methods

effective_dated?() click to toggle source
# File lib/peoplesoft_models/record.rb, line 42
def effective_dated?
  @effective_dated ||= self.keys.include?("effdt")
end
keys() click to toggle source

The useedit field holds many values that you can get from the stored integer by applying bit masks. `useedit & 1` determines whether or not a field is part of the primary key. This operation would be marginally faster on the database, but doing it in Ruby let's us avoid handling different syntaxes for the bitwise AND. www.go-faster.co.uk/peopletools/useedit.htm

# File lib/peoplesoft_models/record.rb, line 34
def keys
  @keys ||= fields.order(:fieldnum).select do |field|
    field.useedit & 1 == 1
  end.map do |field|
    field.fieldname.downcase
  end
end
table_name() click to toggle source

A record's table name “PS_” + the record name unless it's specified in the `sqltablename` field. www.go-faster.co.uk/peopletools/psrecdefn.htm

# File lib/peoplesoft_models/record.rb, line 19
def table_name
  @table_name ||= begin
    schema = self.class.schema_name
    table = self.sqltablename.blank? ? "PS_#{self.recname}" : self.sqltablename
    [schema, table].compact.join(".")
  end
end
to_model() click to toggle source
# File lib/peoplesoft_models/record.rb, line 46
def to_model
  return @model if defined? @model
  @model = Class.new(Base)
  @model.table_name = self.table_name
  @model.primary_keys = self.keys
  @model.extend(EffectiveScope) if self.effective_dated?
  @model
end