Class: MagLoft::TypeloftTheme
- Inherits:
-
RemoteResource
- Object
- RemoteResource
- MagLoft::TypeloftTheme
- Defined in:
- lib/magloft/typeloft_theme.rb
Instance Attribute Summary collapse
-
#javascript_policy ⇒ Object
Returns the value of attribute javascript_policy.
-
#stylesheet_policy ⇒ Object
Returns the value of attribute stylesheet_policy.
Attributes inherited from RemoteResource
#changed_data, #destroyed, #id
Instance Method Summary collapse
- #typeloft_blocks ⇒ Object
- #typeloft_images ⇒ Object
- #typeloft_templates ⇒ Object
- #upload_javascript(file_path) ⇒ Object
- #upload_stylesheet(file_path) ⇒ Object
Methods inherited from RemoteResource
all, #changed?, #clear_changed_data!, create, #destroy, #destroyed?, endpoint, find, find_one, #initialize, method_missing, remote_attribute, remote_attributes, respond_to_missing?, #save, #update_data, where
Constructor Details
This class inherits a constructor from MagLoft::RemoteResource
Instance Attribute Details
#javascript_policy ⇒ Object
Returns the value of attribute javascript_policy.
5 6 7 |
# File 'lib/magloft/typeloft_theme.rb', line 5 def javascript_policy @javascript_policy end |
#stylesheet_policy ⇒ Object
Returns the value of attribute stylesheet_policy.
5 6 7 |
# File 'lib/magloft/typeloft_theme.rb', line 5 def stylesheet_policy @stylesheet_policy end |
Instance Method Details
#typeloft_blocks ⇒ Object
15 16 17 |
# File 'lib/magloft/typeloft_theme.rb', line 15 def typeloft_blocks RemoteCollection.new(TypeloftBlock, { typeloft_theme_id: self.id }) end |
#typeloft_images ⇒ Object
11 12 13 |
# File 'lib/magloft/typeloft_theme.rb', line 11 def typeloft_images RemoteCollection.new(TypeloftImage, { typeloft_theme_id: self.id }) end |
#typeloft_templates ⇒ Object
7 8 9 |
# File 'lib/magloft/typeloft_theme.rb', line 7 def typeloft_templates RemoteCollection.new(TypeloftTemplate, { typeloft_theme_id: self.id }) end |
#upload_javascript(file_path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/magloft/typeloft_theme.rb', line 19 def upload_javascript(file_path) return false if javascript_policy.nil? conn = Faraday.new(url: javascript_policy["url"]) do |f| f.ssl.verify = false f.headers = javascript_policy["headers"] f.adapter :net_http end response = conn.put(nil, File.read(file_path)) return (response.status == 200) end |
#upload_stylesheet(file_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/magloft/typeloft_theme.rb', line 30 def upload_stylesheet(file_path) return false if stylesheet_policy.nil? conn = Faraday.new(url: stylesheet_policy["url"]) do |f| f.ssl.verify = false f.headers = stylesheet_policy["headers"] f.adapter :net_http end response = conn.put(nil, File.read(file_path)) return (response.status == 200) end |