class Bcome::Node::Inventory::Subselect

Public Class Methods

new(*params) click to toggle source
Calls superclass method Bcome::Node::Inventory::Base::new
# File lib/objects/node/inventory/subselect.rb, line 7
def initialize(*params)
  super
  raise Bcome::Exception::MissingSubselectionKey, @views unless @views[:subselect_from]

  update_nodes
end

Public Instance Methods

do_reload() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 53
def do_reload
  parent_inventory.resources.reset_duplicate_nodes!
  parent_inventory.do_reload
  resources.run_subselect
  update_nodes
  nil
end
do_set_resources() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 37
def do_set_resources
  ::Bcome::Node::Resources::SubselectInventory.new(origin_inventory: self, parent_inventory: parent_inventory, filters: filters)
end
enabled_menu_items() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 14
def enabled_menu_items
  super + %i[reload]
end
filters() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 45
def filters
  @views[:sub_filter] || @views[:filters] || {}
end
menu_items() click to toggle source
Calls superclass method Bcome::Node::Inventory::Base#menu_items
nodes_loaded?() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 41
def nodes_loaded?
  true
end
reload() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 49
def reload
  do_reload
end
resources() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 29
def resources
  @resources ||= do_set_resources
end
update_nodes() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 33
def update_nodes
  resources.update_nodes(self)
end

Private Instance Methods

load_parent_inventory() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 67
def load_parent_inventory
  raise ::Bcome::Exception::Generic, "Missing 'subselect_from' attribute on inventory-subselect with config #{@views}" unless @views[:subselect_from]

  parent_crumb = @views[:subselect_from]
  parent = ::Bcome::Node::Factory.instance.bucket[parent_crumb]
  raise Bcome::Exception::CannotFindSubselectionParent, "for key '#{parent_crumb}'" unless parent
  raise Bcome::Exception::CanOnlySubselectOnInventory, "breadcrumb'#{parent_crumb}' represents a #{parent.class}'" unless parent.inventory?

  parent
end
parent_inventory() click to toggle source
# File lib/objects/node/inventory/subselect.rb, line 63
def parent_inventory
  @parent_inventory ||= load_parent_inventory
end