Class: Locomotive::Mounter::Reader::Api::Base
- Inherits:
-
Object
- Object
- Locomotive::Mounter::Reader::Api::Base
- Includes:
- Utils::Output
- Defined in:
- lib/locomotive/mounter/reader/api/base.rb
Direct Known Subclasses
ContentAssetsReader, ContentEntriesReader, ContentTypesReader, PagesReader, SiteReader, SnippetsReader, ThemeAssetsReader, TranslationsReader
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
-
#add_content_asset(url, folder = nil) ⇒ String
Build a new content asset from an url and a folder and add it to the global list of the content assets.
- #get(resource_name, locale = nil, dont_filter_attributes = false) ⇒ Object
-
#initialize(runner) ⇒ Base
constructor
A new instance of Base.
- #mounting_point ⇒ Object
- #read ⇒ Object
Constructor Details
#initialize(runner) ⇒ Base
Returns a new instance of Base.
15 16 17 18 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 15 def initialize(runner) self.runner = runner self.items = {} end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
10 11 12 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 10 def items @items end |
#runner ⇒ Object
Returns the value of attribute runner.
10 11 12 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 10 def runner @runner end |
Instance Method Details
#add_content_asset(url, folder = nil) ⇒ String
Build a new content asset from an url and a folder and add it to the global list of the content assets.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 46 def add_content_asset(url, folder = nil) content_assets = self.mounting_point.resources[:content_assets] if (url =~ /^https?:\/\//).nil? url = URI.join(self.uri_with_scheme, url) else url = URI(url) end asset = Locomotive::Mounter::Models::ContentAsset.new(uri: url, folder: folder) content_assets[url.path] = asset asset.local_filepath end |
#get(resource_name, locale = nil, dont_filter_attributes = false) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 28 def get(resource_name, locale = nil, dont_filter_attributes = false) attribute_names = dont_filter_attributes ? nil : self.safe_attributes begin Locomotive::Mounter::EngineApi.fetch(resource_name, {}, locale, attribute_names) rescue ApiReadException => e raise ReaderException.new(e.) end end |
#mounting_point ⇒ Object
20 21 22 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 20 def mounting_point self.runner.mounting_point end |
#read ⇒ Object
24 25 26 |
# File 'lib/locomotive/mounter/reader/api/base.rb', line 24 def read self.output_title(:pulling) end |