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
- #dev? ⇒ Boolean
-
#initialize(theme) ⇒ APITheme
constructor
A new instance of APITheme.
- #path ⇒ Object
-
#public? ⇒ Boolean
this is unique to API themes.
- #publish ⇒ Object
-
#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.
51 52 53 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 51 def initialize(theme) @theme = theme end |
Instance Method Details
#add_asset(file_name, file) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 103 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
91 92 93 94 95 96 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 91 def add_template(file_name, body) check_errors! theme.create_template( file_name: file_name, body: body ) end |
#assets ⇒ Object
87 88 89 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 87 def assets @assets ||= theme.assets.map { |t| APIAsset.new(t) } end |
#dev? ⇒ Boolean
60 61 62 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 60 def dev? theme.can?(:publish_theme) end |
#path ⇒ Object
71 72 73 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 71 def path theme.rels[:theme_preview].href end |
#public? ⇒ Boolean
this is unique to API themes
56 57 58 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 56 def public? !dev? end |
#publish ⇒ Object
64 65 66 67 68 69 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 64 def publish if theme.can?(:publish_theme) @theme = theme.publish_theme reload!(false) end end |
#reload!(refetch = true) ⇒ Object
Implement generic Theme interface
76 77 78 79 80 81 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 76 def reload!(refetch = true) @templates = nil @assets = nil @theme = theme.self if refetch self end |
#remove_asset(file_name) ⇒ Object
110 111 112 113 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 110 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
98 99 100 101 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 98 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
83 84 85 |
# File 'lib/bootic_cli/themes/api_theme.rb', line 83 def templates @templates ||= theme.templates.map { |t| ItemWithTime.new(t) } end |