Class: Plutonium::UI::Display::Resource
- Defined in:
- lib/plutonium/ui/display/resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource_associations ⇒ Object
readonly
Returns the value of attribute resource_associations.
-
#resource_definition ⇒ Object
readonly
Returns the value of attribute resource_definition.
-
#resource_fields ⇒ Object
readonly
Returns the value of attribute resource_fields.
Instance Method Summary collapse
- #display_template ⇒ Object
-
#initialize(resource_fields:, resource_associations:, resource_definition:) ⇒ Resource
constructor
A new instance of Resource.
-
#metadata_fields ⇒ Object
Metadata fields the user is permitted to see — intersection of the definition’s declared metadata with the policy-filtered ‘resource_fields`.
Methods included from Component::Behaviour
Methods included from Component::Tokens
Methods included from Component::Kit
#BuildActionButton, #BuildActionsDropdown, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?
Constructor Details
#initialize(resource_fields:, resource_associations:, resource_definition:) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 14 |
# File 'lib/plutonium/ui/display/resource.rb', line 9 def initialize(*, resource_fields:, resource_associations:, resource_definition:, **, &) super(*, **, &) @resource_fields = resource_fields @resource_associations = resource_associations @resource_definition = resource_definition end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Attribute Details
#resource_associations ⇒ Object (readonly)
Returns the value of attribute resource_associations.
7 8 9 |
# File 'lib/plutonium/ui/display/resource.rb', line 7 def resource_associations @resource_associations end |
#resource_definition ⇒ Object (readonly)
Returns the value of attribute resource_definition.
7 8 9 |
# File 'lib/plutonium/ui/display/resource.rb', line 7 def resource_definition @resource_definition end |
#resource_fields ⇒ Object (readonly)
Returns the value of attribute resource_fields.
7 8 9 |
# File 'lib/plutonium/ui/display/resource.rb', line 7 def resource_fields @resource_fields end |
Instance Method Details
#display_template ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/plutonium/ui/display/resource.rb', line 24 def display_template if associations_present? render_tablist_with_details else render_fields end end |
#metadata_fields ⇒ Object
Metadata fields the user is permitted to see — intersection of the definition’s declared metadata with the policy-filtered ‘resource_fields`. Computed lazily so we don’t run the intersection when the resource doesn’t declare any metadata.
20 21 22 |
# File 'lib/plutonium/ui/display/resource.rb', line 20 def @metadata_fields ||= resource_definition. & resource_fields end |