Class: OembedProviderEngine::OembedProvider
- Inherits:
-
Object
- Object
- OembedProviderEngine::OembedProvider
- Defined in:
- app/models/oembed_provider_engine/oembed_provider.rb
Overview
set OembedProvider.provider_name, etc. in your config/initializers or somewhere
Class Method Summary collapse
-
.base_attributes ⇒ Object
every request has these, mostly required mostly site wide version is special case.
- .cache_age ⇒ Object
- .cache_age=(age) ⇒ Object
- .controller_model_maps ⇒ Object
- .controller_model_maps=(hash_map) ⇒ Object
- .find_provided_from(url) ⇒ Object
-
.optional_attributes ⇒ Object
optional attributes that are specific to an instance of the providable model.
- .provider_name ⇒ Object
- .provider_name=(name) ⇒ Object
- .provider_url ⇒ Object
- .provider_url=(url) ⇒ Object
-
.required_attributes ⇒ Object
these may be required depending on type see 2.3.4.1 - 2.3.4.4 of spec type specific attributes all attributes listed for these types are required the empty link array shows that nothing is required.
- .version ⇒ Object
Class Method Details
permalink .base_attributes ⇒ Object
every request has these, mostly required mostly site wide version is special case
38 39 40 41 42 43 44 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 38 def base_attributes [:provider_url, :provider_name, :cache_age, :type, :version] end |
permalink .cache_age ⇒ Object
[View source]
23 24 25 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 23 def cache_age @@cache_age ||= nil end |
permalink .cache_age=(age) ⇒ Object
[View source]
27 28 29 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 27 def cache_age=(age) @@cache_age = age end |
permalink .controller_model_maps ⇒ Object
[View source]
69 70 71 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 69 def controller_model_maps @@controller_model_maps ||= Hash.new end |
permalink .controller_model_maps=(hash_map) ⇒ Object
[View source]
73 74 75 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 73 def controller_model_maps=(hash_map) @@controller_model_maps = hash_map end |
permalink .find_provided_from(url) ⇒ Object
[View source]
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 77 def find_provided_from(url) url = Addressable::URI.parse(url) #TODO smell submitted_url_params = Rails.application.routes.recognize_path(url.path, :method=>:get) controller = submitted_url_params[:controller] id = submitted_url_params[:id] # handle special cases where controllers are directly configured to point at a specific model model = OembedProvider.controller_model_maps[controller] # otherwise we use convention over configuration to determine model model = controller.singularize.camelize unless model model.constantize.find(id) end |
permalink .optional_attributes ⇒ Object
optional attributes that are specific to an instance of the providable model
48 49 50 51 52 53 54 55 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 48 def optional_attributes [:title, :author_name, :author_url, :thumbnail_url, :thumbnail_width, :thumbnail_height] end |
permalink .provider_name ⇒ Object
[View source]
15 16 17 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 15 def provider_name @@provider_name ||= String.new end |
permalink .provider_name=(name) ⇒ Object
[View source]
19 20 21 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 19 def provider_name=(name) @@provider_name = name end |
permalink .provider_url ⇒ Object
[View source]
7 8 9 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 7 def provider_url @@provider_url ||= String.new end |
permalink .provider_url=(url) ⇒ Object
[View source]
11 12 13 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 11 def provider_url=(url) @@provider_url = url end |
permalink .required_attributes ⇒ Object
these may be required depending on type see 2.3.4.1 - 2.3.4.4 of spec type specific attributes all attributes listed for these types are required the empty link array shows that nothing is required
62 63 64 65 66 67 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 62 def required_attributes { :photo => [:url, :width, :height], :video => [:html, :width, :height], :link => [], :rich => [:html, :width, :height] } end |
permalink .version ⇒ Object
[View source]
31 32 33 |
# File 'app/models/oembed_provider_engine/oembed_provider.rb', line 31 def version "1.0" end |