Module: Workbook::Modules::RawObjectsStorage
Overview
Adds support for storing raw objects, used in e.g. Format and Template
Instance Method Summary collapse
-
#add_raw(raw_object, options = {}) ⇒ Object
A raw is a ‘raw’ object, representing a workbook, or cell, or whatever…
-
#available_raws ⇒ Array<Object>
Lists the classes for which raws are available.
-
#has_raw_for?(raw_object_class) ⇒ Boolean
Returns true if there is a template for a certain class, otherwise false.
-
#raws ⇒ Object
Return all raw data references.
-
#remove_all_raws! ⇒ Object
Remove all raw data references.
-
#return_raw_for(raw_object_class) ⇒ Object
Returns raw data stored for a type of raw object (if available).
Instance Method Details
#add_raw(raw_object, options = {}) ⇒ Object
A raw is a ‘raw’ object, representing a workbook, or cell, or whatever… in a particular format (defined by its class)
11 12 13 14 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 11 def add_raw raw_object, ={} class_of_obj = [:raw_object_class] ? [:raw_object_class] : raw_object.class raws[class_of_obj]=raw_object end |
#available_raws ⇒ Array<Object>
Lists the classes for which raws are available
35 36 37 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 35 def available_raws raws.keys end |
#has_raw_for?(raw_object_class) ⇒ Boolean
Returns true if there is a template for a certain class, otherwise false
17 18 19 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 17 def has_raw_for? raw_object_class available_raws.include? raw_object_class end |
#raws ⇒ Object
Return all raw data references
40 41 42 43 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 40 def raws @raws = {} unless defined? @raws @raws end |
#remove_all_raws! ⇒ Object
Remove all raw data references
29 30 31 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 29 def remove_all_raws! @raws = {} end |
#return_raw_for(raw_object_class) ⇒ Object
Returns raw data stored for a type of raw object (if available)
23 24 25 26 |
# File 'lib/workbook/modules/raw_objects_storage.rb', line 23 def return_raw_for raw_object_class raws.each { |tc,t| return t if tc == raw_object_class} return nil end |