Module: Avo::Concerns::IsResourceItem

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#resourceObject

These attributes are required to be hydrated in order to properly find the visible_items



6
7
8
# File 'lib/avo/concerns/is_resource_item.rb', line 6

def resource
  @resource
end

#viewObject

Returns the value of attribute view.



7
8
9
# File 'lib/avo/concerns/is_resource_item.rb', line 7

def view
  @view
end

Instance Method Details

#hydrate(**args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/avo/concerns/is_resource_item.rb', line 9

def hydrate(**args)
  args.each do |key, value|
    if respond_to?("#{key}=")
      send("#{key}=", value)
    end
  end

  self
end

#visible?Boolean

Returns the final state of if an item is visible or not For items that have children it checks to see if it contains any visible children.

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/avo/concerns/is_resource_item.rb', line 21

def visible?
  # For items that may contains other items like tabs and panels we should also check
  # if any on their children have visible items.
  if self.class.ancestors.include?(Avo::Concerns::HasItems)
    return false unless visible_items.any?
  end

  super
end