Module: SocialButtons::Tweet

Includes:
Assistant
Defined in:
lib/social_buttons/view_helpers/tweet.rb

Defined Under Namespace

Classes: Scripter

Constant Summary collapse

TWITTER_SHARE_URL =
"http://twitter.com/share"
CLASS =
"twitter-share-button"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_optionsObject



27
28
29
30
31
32
33
34
35
# File 'lib/social_buttons/view_helpers/tweet.rb', line 27

def default_options
  @default_options ||= {
    via:    "tweetbutton",
    text:   "",
    count:  "vertical",
    lang:   "en",
    related: ""
  }
end

Instance Method Details

#tweet_button(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/social_buttons/view_helpers/tweet.rb', line 8

def tweet_button(options = {})
  clazz = SocialButtons::Tweet

  # JUNK Code! Refactor!!!!
  params = {}

  params.merge!(url: request.url)
  opt_params = clazz.default_options.merge(options)

  params = clazz.options_to_data_params(opt_params)
  params.merge!(:class => CLASS)

  html = "".html_safe
  html << clazz::Scripter.new(self).script
  html << link_to("Tweet", TWITTER_SHARE_URL, params)
  html
end