Module: Ui::Actionable
- Included in:
- Card, Collapse::Panel, DescriptiveList, Empty, List, Notification, PageHeader, Table
- Defined in:
- lib/ui/actionable.rb
Constant Summary collapse
- Actions =
Types::Array.default([].freeze).of(Types::Callable)
Instance Method Summary collapse
- #actions(object = model) ⇒ Object
- #actions_length ⇒ Object
- #actions_list ⇒ Object
- #has_actions? ⇒ Boolean
Instance Method Details
#actions(object = model) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/ui/actionable.rb', line 5 def actions(object = model) content_tag(:nav, class: 'ui-actions', role: 'navigation') do render_group( actions_list.map do |action| action.call(object) end ) end end |
#actions_length ⇒ Object
26 27 28 |
# File 'lib/ui/actionable.rb', line 26 def actions_length .fetch(:actions, Array.new).size end |
#actions_list ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ui/actionable.rb', line 15 def actions_list begin Actions[.fetch(:actions, Array.new)] rescue Dry::Types::ConstraintError raise Ui::Errors::InvalidActions.new( "Actions for #{self.class.to_s} are invalid. Ensure you are passing " \ "an array of callable objects that will be passed a model" ) end end |
#has_actions? ⇒ Boolean
30 31 32 |
# File 'lib/ui/actionable.rb', line 30 def has_actions? actions_list.any? end |