Class: OMF::Web::ContentProxy
- Inherits:
-
Common::LObject
- Object
- Common::LObject
- OMF::Web::ContentProxy
- Defined in:
- lib/omf-web/content/content_proxy.rb
Overview
This object maintains synchronization between a JS DataSource object in a web browser and the corresponding OmlTable
in this server.
Constant Summary collapse
- @@proxies =
{}
Instance Attribute Summary collapse
-
#content_descriptor ⇒ Object
readonly
Returns the value of attribute content_descriptor.
-
#content_id ⇒ Object
readonly
Returns the value of attribute content_id.
-
#content_url ⇒ Object
readonly
Returns the value of attribute content_url.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object (also: #read)
- #on_get(req) ⇒ Object
- #on_post(req) ⇒ Object
- #write(content, message = "") ⇒ Object
Methods included from Common::Loggable
#_logger, #debug, #error, #fatal, #info, init_log, logger, set_environment, #warn
Instance Attribute Details
#content_descriptor ⇒ Object (readonly)
Returns the value of attribute content_descriptor.
31 32 33 |
# File 'lib/omf-web/content/content_proxy.rb', line 31 def content_descriptor @content_descriptor end |
#content_id ⇒ Object (readonly)
Returns the value of attribute content_id.
31 32 33 |
# File 'lib/omf-web/content/content_proxy.rb', line 31 def content_id @content_id end |
#content_url ⇒ Object (readonly)
Returns the value of attribute content_url.
31 32 33 |
# File 'lib/omf-web/content/content_proxy.rb', line 31 def content_url @content_url end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
31 32 33 |
# File 'lib/omf-web/content/content_proxy.rb', line 31 def mime_type @mime_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/omf-web/content/content_proxy.rb', line 31 def name @name end |
Class Method Details
.[](url) ⇒ Object
16 17 18 |
# File 'lib/omf-web/content/content_proxy.rb', line 16 def self.[](url) @@proxies[url.to_s] end |
.create(content_descr, repo) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/omf-web/content/content_proxy.rb', line 20 def self.create(content_descr, repo) unless key = content_descr[:url_key] raise "Missing ':url_key' in content descriptor '#{content_descr.inspect}'" end if proxy = @@proxies[key] return proxy end debug "Create content proxy for '#{key}' (#{content_descr.inspect})" @@proxies[key] = self.new(content_descr, repo) end |
Instance Method Details
#content ⇒ Object Also known as: read
57 58 59 60 61 62 |
# File 'lib/omf-web/content/content_proxy.rb', line 57 def content() unless @content @content = @repository.read(@content_descriptor) end @content end |
#on_get(req) ⇒ Object
34 35 36 37 |
# File 'lib/omf-web/content/content_proxy.rb', line 34 def on_get(req) c = content() [c.to_s, "text"] end |
#on_post(req) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/omf-web/content/content_proxy.rb', line 39 def on_post(req) data = req.POST write(data['content'], data['message']) # if (content = data['content']) != @content # @content = content # @repository.add_and_commit(@content_handle, content, data['message'], req) # end [true.to_json, "text/json"] end |
#write(content, message = "") ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/omf-web/content/content_proxy.rb', line 49 def write(content, = "") if content != @content debug "Updating '#{@content_descriptor.inspect}'" @content = content @repository.write(@content_descriptor, content, ) end end |