Sha256: c40bd153bb72ae39f05b1dd4ba330c40860dad2e58184c9cca3fcdaaa2e877ce

Contents?: true

Size: 992 Bytes

Versions: 3

Compression:

Stored size: 992 Bytes

Contents

module Xeroizer
  class PayrollApplication

    attr_reader :application

    # Factory for new Payroll BaseModel instances with the class name `record_type`.
    # Only creates the instance if one doesn't already exist.
    #
    # @param [Symbol] record_type Symbol of the record type (e.g. :Invoice)
    # @return [BaseModel] instance of BaseModel subclass matching `record_type`
    def self.record(record_type)
      define_method record_type do
        var_name = "@#{record_type}_cache".to_sym
        unless instance_variable_defined?(var_name)
          instance_variable_set(var_name, Xeroizer::Record::Payroll.const_get("#{record_type}Model".to_sym).new(self.application, record_type.to_s))
        end
        instance_variable_get(var_name)
      end
    end

    record :Employee
    record :PayRun
    record :Paystub
    record :PayItems
    record :PaySchedule
    record :LeaveApplication

    def initialize(application)
      @application = application
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
xeroizer-3.0.1 lib/xeroizer/payroll_application.rb
xeroizer-3.0.0 lib/xeroizer/payroll_application.rb
xeroizer-3-pre-beta-3.0.0.pre.beta lib/xeroizer/payroll_application.rb