module ErpBaseErpSvcs::Extensions::ActiveRecord::ActsAsErpType::ActsAsSingletonMethods

Adds singleton methods.

Public Instance Methods

eid( external_identifier_string ) click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 67
                      def eid( external_identifier_string )
where('external_identifier = ?', external_identifier_string.to_s).first
                      end
generate_unique_iid(name) click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 75
def generate_unique_iid(name)
  iid = name.to_iid

  iid_exists = true
  iid_test = iid
  iid_counter = 1
  while iid_exists
    if self.where(internal_identifier: iid_test).first
      iid_test = "#{iid}_#{iid_counter}"
      iid_counter += 1
    else
      iid_exists = false
      iid = iid_test
    end
  end

  iid
end
iid( internal_identifier_string ) click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 71
                        def iid( internal_identifier_string )
  where('internal_identifier = ?', internal_identifier_string.to_s).first
end
valid_type?( type_name_string ) click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 62
                      def valid_type?( type_name_string )
sym_list = self.all.collect{ |type| type.internal_identifier.to_sym }
sym_list.include?(type_name_string.to_sym)
                      end
valid_types() click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 58
                      def valid_types
self.all.collect{ |type| type.internal_identifier.to_sym }
                      end