Class: VoteFu::VoteWidgetComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- VoteFu::VoteWidgetComponent
- Defined in:
- app/components/vote_fu/vote_widget_component.rb
Instance Attribute Summary collapse
-
#voteable ⇒ Object
readonly
The voteable record.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(voteable:, voter: nil, scope: nil, variant: :default, upvote_label: "▲", downvote_label: "▼", show_count: true, count_format: :plusminus) ⇒ VoteWidgetComponent
constructor
A new instance of VoteWidgetComponent.
Constructor Details
#initialize(voteable:, voter: nil, scope: nil, variant: :default, upvote_label: "▲", downvote_label: "▼", show_count: true, count_format: :plusminus) ⇒ VoteWidgetComponent
Returns a new instance of VoteWidgetComponent.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/vote_fu/vote_widget_component.rb', line 16 def initialize( voteable:, voter: nil, scope: nil, variant: :default, upvote_label: "▲", downvote_label: "▼", show_count: true, count_format: :plusminus ) @voteable = voteable @voter = voter @scope = scope @variant = variant @upvote_label = upvote_label @downvote_label = downvote_label @show_count = show_count @count_format = count_format end |
Instance Attribute Details
#voteable ⇒ Object (readonly)
The voteable record
6 7 8 |
# File 'app/components/vote_fu/vote_widget_component.rb', line 6 def voteable @voteable end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/components/vote_fu/vote_widget_component.rb', line 36 def call tag.div(**wrapper_attributes) do safe_join([ , (count_display if @show_count), ].compact) end end |