Module: GetShorty::ClassMethods
- Defined in:
- lib/get_shorty.rb
Instance Method Summary collapse
- #has_short_url(options = {}) ⇒ Object
-
#set_long_url_host(value) ⇒ Object
for Rails when using UrlWriter.
-
#short_url_options ⇒ Object
Returns the short_url_options defined by each call to has_short_url.
- #shortening_serivce ⇒ Object
Instance Method Details
#has_short_url(options = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/get_shorty.rb', line 20 def has_short_url(={}) include InstanceMethods include ActionController::UrlWriter if defined?(ActionController )# non mvc - but need to know the url for model instance to persist the short_url. @short_url_options = {:long_url_method => :generate_long_url, :short_url_method => :short_url}.update() @shortening_serivce = [:shortener_service] || Bitly::Client.connection set_long_url_host [:long_url_host] end |
#set_long_url_host(value) ⇒ Object
for Rails when using UrlWriter
29 30 31 32 33 34 35 |
# File 'lib/get_shorty.rb', line 29 def set_long_url_host(value) self.[:host] = if value.is_a?(Hash) && defined?(Rails) value.stringify_keys[Rails.env] else value end end |
#short_url_options ⇒ Object
Returns the short_url_options defined by each call to has_short_url.
12 13 14 |
# File 'lib/get_shorty.rb', line 12 def @short_url_options end |
#shortening_serivce ⇒ Object
16 17 18 |
# File 'lib/get_shorty.rb', line 16 def shortening_serivce @shortening_serivce end |