Class: UnitOfMeasurement

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ErpTechSvcs::Utils::DefaultNestedSetMethods
Defined in:
app/models/unit_of_measurement.rb

Overview

create_table :unit_of_measurements do |t| t.string :description t.string :domain t.string :internal_identifier t.string :comments t.string :external_identifier t.string :external_id_source

t.integer :lft
t.integer :rgt
t.integer :parent_id

t.timestamps

end

add_index :unit_of_measurements, :lft add_index :unit_of_measurements, :rgt add_index :unit_of_measurements, :parent_id

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.scope_by_dba_organization(dba_organization) ⇒ ActiveRecord::Relation

scope by dba organization

scope by

Parameters:

  • dba_organization (Party, Array) —

    dba organization to scope by or Array of dba organizations to

Returns:

  • (ActiveRecord::Relation)


37
38
39
40
# File 'app/models/unit_of_measurement.rb', line 37

def scope_by_dba_organization(dba_organization)
  joins(:party_unit_of_measurements)
      .where({party_unit_of_measurements: {party_id: dba_organization}})
end

Instance Method Details

#to_data_hash ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/unit_of_measurement.rb', line 43

def to_data_hash
  to_hash(only: [:id,
                 :description,
                 :domain,
                 :internal_identifier,
                 :comments,
                 :external_identifier,
                 :external_id_source,
                 :created_at,
                 :updated_at])
end