Class: BooticCli::Themes::APITheme
- Inherits:
-
Object
- Object
- BooticCli::Themes::APITheme
- Defined in:
- lib/bootic_cli/themes/api_theme.rb
Defined Under Namespace
Classes: EntityErrors
Instance Method Summary collapse
- #add_asset(file_name, file) ⇒ Object
- #add_template(file_name, body) ⇒ Object
- #assets ⇒ Object
-
#initialize(theme) ⇒ APITheme
constructor
A new instance of APITheme.
- #path ⇒ Object
-
#publish(clone = false) ⇒ Object
this is unique to API themes.
-
#reload!(refetch = true) ⇒ Object
Implement generic Theme interface.
- #remove_asset(file_name) ⇒ Object
- #remove_template(file_name) ⇒ Object
- #templates ⇒ Object
Constructor Details
#initialize(theme) ⇒ APITheme
Returns a new instance of APITheme.
22 23 24 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 22 def initialize(theme) @theme = theme end |
Instance Method Details
#add_asset(file_name, file) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 67 def add_asset(file_name, file) check_errors! theme.create_theme_asset( file_name: file_name, data: file ) end |
#add_template(file_name, body) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 55 def add_template(file_name, body) check_errors! theme.create_template( file_name: file_name, body: body ) end |
#assets ⇒ Object
51 52 53 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 51 def assets @assets ||= theme.assets.map{|t| APIAsset.new(t) } end |
#path ⇒ Object
35 36 37 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 35 def path theme.rels[:theme_preview].href end |
#publish(clone = false) ⇒ Object
this is unique to API themes
27 28 29 30 31 32 33 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 27 def publish(clone = false) if theme.can?(:publish_theme) @theme = theme.publish_theme @theme.create_dev_theme if clone reload!(false) end end |
#reload!(refetch = true) ⇒ Object
Implement generic Theme interface
40 41 42 43 44 45 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 40 def reload!(refetch = true) @templates = nil @assets = nil @theme = theme.self if refetch self end |
#remove_asset(file_name) ⇒ Object
74 75 76 77 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 74 def remove_asset(file_name) asset = theme.assets.find{|t| t.file_name == file_name } check_errors!(asset.delete_theme_asset) if asset end |
#remove_template(file_name) ⇒ Object
62 63 64 65 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 62 def remove_template(file_name) tpl = theme.templates.find { |t| t.file_name == file_name } check_errors!(tpl.delete_template) if tpl && tpl.can?(:delete_template) end |
#templates ⇒ Object
47 48 49 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 47 def templates @templates ||= theme.templates.map{|t| ItemWithTime.new(t) } end |