Class: MagLoft::TypeloftTheme

Inherits:
RemoteResource show all
Defined in:
lib/magloft/typeloft_theme.rb

Instance Attribute Summary collapse

Attributes inherited from RemoteResource

#destroyed, #id

Instance Method Summary collapse

Methods inherited from RemoteResource

all, #changed?, #changed_data, #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_policyObject

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_policyObject

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_blocksObject



15
16
17
# File 'lib/magloft/typeloft_theme.rb', line 15

def typeloft_blocks
  RemoteCollection.new(TypeloftBlock, { typeloft_theme_id: self.id })
end

#typeloft_imagesObject



11
12
13
# File 'lib/magloft/typeloft_theme.rb', line 11

def typeloft_images
  RemoteCollection.new(TypeloftImage, { typeloft_theme_id: self.id })
end

#typeloft_templatesObject



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