Class: PeoplesoftModels::Record
- Defined in:
- lib/peoplesoft_models/record.rb
Class Method Summary collapse
Instance Method Summary collapse
- #effective_dated? ⇒ Boolean
-
#keys ⇒ Object
The useedit field holds many values that you can get from the stored integer by applying bit masks.
-
#table_name ⇒ Object
A record’s table name “PS_” + the record name unless it’s specified in the ‘sqltablename` field.
- #to_model ⇒ Object
Class Method Details
.table_name ⇒ Object
11 12 13 |
# File 'lib/peoplesoft_models/record.rb', line 11 def self.table_name [self.schema_name, "PSRECDEFN"].compact.join(".") end |
Instance Method Details
#effective_dated? ⇒ Boolean
42 43 44 |
# File 'lib/peoplesoft_models/record.rb', line 42 def effective_dated? @effective_dated ||= self.keys.include?("effdt") end |
#keys ⇒ Object
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
34 35 36 37 38 39 40 |
# 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 ⇒ Object
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
19 20 21 22 23 24 25 |
# 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 ⇒ Object
46 47 48 49 50 51 52 53 |
# 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 |