Class: Toolhound::Inventory
- Defined in:
- lib/toolhound-ruby/inventory.rb
Overview
Class to parse GitHub repository owner and name from URLs and to generate URLs
Constant Summary
Constants inherited from Base
Base::DATE_TIME_FORMAT, Base::DB_TYPE_REGEX
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_join(join) ⇒ Object
def joins # LEFT OUTER JOIN tblInventoryID ON tblInventoryID.intInventoryID = tblInventory.intInventoryID [ :inner, table: :inventory_type, on: “intInventoryTypeID”, :inner, table: :inventory_text, on: [“intInventoryTypeID”, varLocaleID: locale], :left_outer, table: :unit_of_measure_text, on: “intUofMID”, :left_outer, table: :category_text, on: [“intUofMID”, varLocaleID: locale], as: :category,.
- #default_joins ⇒ Object
- #default_selects ⇒ Object
- #default_wheres ⇒ Object
Methods inherited from Base
#_build_joins, #_build_selects, #_build_where, #all, #build_and_query, #build_group, #build_joins, #build_selects, #build_sql, #build_update_attributes, #build_update_sql, #build_where, #find, #formatted_table_and_column, #formatted_table_name, #formmatted_column_name, #get_operator, #initialize, #insert, #locale, #merge_options, #parse_time, primary_key, #primary_key, primary_key=, #procedure, #query, rename_attributes, renamed_attributes, #table_name, table_name, table_name=, #transform_attribute_key, #transform_attributes, #transform_procedure_key, #transform_procedure_value, #transform_procedure_variables, #update, #update_query
Methods included from Util
#acronym_regex, #acronyms, #camelize, #demodulize, #underscore
Constructor Details
This class inherits a constructor from Toolhound::Base
Instance Method Details
#build_join(join) ⇒ Object
def joins
# LEFT OUTER JOIN tblInventoryID ON tblInventoryID.intInventoryID = tblInventory.intInventoryID
[
{type: :inner, table: :inventory_type, on: "intInventoryTypeID"},
{type: :inner, table: :inventory_text, on: ["intInventoryTypeID", varLocaleID: locale]},
{type: :left_outer, table: :unit_of_measure_text, on: "intUofMID"},
{type: :left_outer, table: :category_text, on: ["intUofMID", varLocaleID: locale], as: :category},
]
arr.join(" ")
end
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/toolhound-ruby/inventory.rb', line 58 def build_join(join) join_types = { inner: "INNER JOIN", left: "LEFT OUTER JOIN", left_outer: "LEFT OUTER JOIN", left_inner: "LEFT INNER JOIN", right: "RIGHT OUTER JOIN", right_outer: "RIGHT OUTER JOIN", right_inner: "RIGHT INNER JOIN", } type = join_types[join[:type] || :inner] table = formatted_table_name(join[:table]) table_str = "#{table} " if join[:as] table = formatted_table_name(join[:as]) table_str += "AS #{table} " end on = join[:on] case on.class.to_s when "String" end # on_str = on ? "ON #{on}" : "" "#{type} #{table_str} #{on_str}" end |
#default_joins ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/toolhound-ruby/inventory.rb', line 25 def default_joins arr = [] arr << "INNER JOIN tblInventoryType ON tblInventory.intInventoryTypeID = tblInventoryType.intInventoryTypeID" arr << "INNER JOIN tblInventoryText ON (tblInventoryText.intInventoryID = tblInventory.intInventoryID AND tblInventoryText.varLocaleID = '#{locale}')" arr << "LEFT OUTER JOIN tblUnitOfMeasureText ON (tblUnitOfMeasureText.intUofMID = tblInventory.intUofMID )" arr << "LEFT OUTER JOIN tblCategoryText AS tblCategory ON (tblCategory.intCategoryID = tblInventory.intCategoryID AND tblCategory.varLocaleID = '#{locale}')" arr << "LEFT OUTER JOIN tblCategoryText AS tblSubCategory ON (tblSubCategory.intCategoryID = tblInventory.intSubCategoryID AND tblSubCategory.varLocaleID = '#{locale}')" end |
#default_selects ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/toolhound-ruby/inventory.rb', line 15 def default_selects selects = { inventory: ["intInventoryID", "intCategoryID", "intSubCategoryID", "intManufacturerID", "intVendorID", "dteCreatedDate", "dteModifiedDate"], inventory_text: ["varPartNo", "varDescription", "txtNotes", {varUserField1: "varGlRevenue"}, {varUserField2: "varGlCOGSCode"}, {varUserField3: "varPhaseCode"}], unit_of_measure_text: ["varUnitOfMeasure"], category: ["varCategory"], sub_category: [{varCategory: "varSubcategory"}] } end |
#default_wheres ⇒ Object
34 35 36 |
# File 'lib/toolhound-ruby/inventory.rb', line 34 def default_wheres [{bolIsActive: 1}, {bolDeleted: 0}] end |