Sha256: 03b81ee7400ee62b7cea2d3d7d45d29c20e8791a88ad795b7a6eea90942a4e40
Contents?: true
Size: 1 KB
Versions: 10
Compression:
Stored size: 1 KB
Contents
module Neutral module VotingBuilder class Builder include ActionView::Helpers::TagHelper include ActionView::Helpers::OutputSafetyHelper include Elements attr_reader :voteable, :voter, :icons, :difference def initialize(voteable, options) @voteable = voteable @voter = options[:voter] @icons = options[:icons] || Neutral.config.default_icon_set @difference = options[:difference] end def build content_tag :div, elements, class: 'neutral' end private def elements safe_join(structure.map { |element| send(element) }) end def voting voteable.voting || Neutral::Voting.new end def vote @vote ||= voter && voteable.votes.where(voter_id: voter.id).first_or_initialize || voteable.votes.new end def router @router ||= Router.new vote end def structure Structure.new(vote.persisted?, difference).to_a end end end end
Version data entries
10 entries across 10 versions & 1 rubygems