Module: TooShort::ARBaseExtensions
- Defined in:
- lib/ar_base_extensions.rb
Instance Method Summary collapse
-
#has_a_short_url(options = {}) ⇒ Object
To be included in your model, i.e class Post has_a_short_url end.
Instance Method Details
#has_a_short_url(options = {}) ⇒ Object
To be included in your model, i.e class Post
has_a_short_url
end
Takes the following options:
host: short URL host to use (alternatively to be defined in an initializer file)
scope: the scope for this model, necessary when short URLs are used in multiple models
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ar_base_extensions.rb', line 14 def has_a_short_url(={}) = TooShort..merge() .symbolize_keys! class_attribute :short_url_options self. = TooShort.register_class(self.to_s, [:scope]) class_eval do include InstanceMethods end end |