Sha256: af627011f178eb0e393b05704dd79fed4854416be89c800a08306b311b3d6187

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module Neutral
  module VotingBuilder
    module Elements
      class Link
        include ActionView::Helpers::TagHelper
        include ActionView::Helpers::UrlHelper

        def initialize(router, icon)
          @router = router
          @icon = icon
        end

        private
        def fa_icon
          "fa #{@icon}"
        end

        def path
          @router[:path]
        end

        def verb
          @router[:method]
        end

        class Positive < Link
          def to_s
            link_to content_tag(:i, nil, class: fa_icon), path, class: 'positive', method: verb, remote: true
          end
        end

        class Negative < Link
          def to_s
            link_to content_tag(:i, nil, class: fa_icon), path, class: 'negative', method: verb, remote: true
          end
        end

        class Remove < Link
          def to_s
            link_to content_tag(:i, nil, class: fa_icon), path, class: 'remove', method: verb, remote: true
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neutral-0.0.10 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.9 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.8 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.7 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.6 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.5 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.4 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.3 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.2 lib/neutral/voting_builder/elements/link.rb
neutral-0.0.1 lib/neutral/voting_builder/elements/link.rb