Class: Card::View
- Inherits:
-
Object
- Object
- Card::View
- Extended by:
- Cache::ClassMethods
- Includes:
- Cache, CacheAction, Options, Stub, Visibility
- Defined in:
- lib/card/view.rb,
lib/card/view/stub.rb,
lib/card/view/cache.rb,
lib/card/view/options.rb,
lib/card/view/visibility.rb,
lib/card/view/cache_action.rb,
lib/card/view/options/voo_api.rb,
lib/card/view/options/key_lists.rb
Defined Under Namespace
Modules: Cache, CacheAction, Options, Stub, Visibility
Constant Summary
Constants included from CacheAction
CacheAction::ACTIVE_CACHE_LEVEL
Constants included from Visibility
Instance Attribute Summary collapse
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes included from Options::VooApi
Class Method Summary collapse
Instance Method Summary collapse
-
#deep_root? ⇒ true/false
neither view nor format has a parent.
-
#initialize(format, view, raw_options = {}, parent = nil) ⇒ View
constructor
A new instance of View.
-
#next_ancestor ⇒ Card::View
next voo object found tracing ancestry through parent voos and/or parent formats.
-
#ok_view ⇒ Symbol
the final view.
-
#process ⇒ rendered view or a stub
handle rendering, including optional visibility, permissions, and caching.
-
#requested_view ⇒ Symbol
the view to “attempt”.
-
#root ⇒ Card::View
-
#root? ⇒ true/false
Methods included from Cache::ClassMethods
Methods included from CacheAction
#active_cache_action, #active_cache_action_from_setting, #active_cache_ok?, #active_cache_permissible?, #cache_action, #cache_on?, #cache_setting, #cache_status, #clean_enough_to_cache?, #free_cache_action, #free_cache_ok?, #log_cache_action, #off_cache_action, #permission_task
Methods included from Options
Methods included from Options::KeyLists
#accessible_keys, #all_keys, #heir_keys, #reset_key_lists, #ruler_keys
Methods included from Options::VooApi
define_getter, define_setter, included, #items, #normalize_cache, #normalize_editor, #slot_options
Methods included from Stub
escape, #stub, #stub_hash, #stub_json, unescape
Methods included from Cache
#array_for_cache_key, #cache_active?, #cache_fetch, #cache_key, #cache_render, #caching, #fetch, #hash_for_cache_key, #option_for_cache_key, #option_value_to_string, #options_for_cache_key, #register_cache_key
Methods included from Visibility
#hide, #hide!, #hide?, #optional?, #process_visibility, #process_visibility_options, #show, #show!, #show?, #visible?, #viz, #viz_hash, #viz_view_list
Constructor Details
#initialize(format, view, raw_options = {}, parent = nil) ⇒ View
Returns a new instance of View.
27 28 29 30 31 32 33 34 35 |
# File 'lib/card/view.rb', line 27 def initialize format, view, ={}, parent=nil @format = format @raw_view = view @raw_options = @parent = parent @card = @format.card end |
Instance Attribute Details
#card ⇒ Object (readonly)
Returns the value of attribute card.
16 17 18 |
# File 'lib/card/view.rb', line 16 def card @card end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
16 17 18 |
# File 'lib/card/view.rb', line 16 def format @format end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
16 17 18 |
# File 'lib/card/view.rb', line 16 def parent @parent end |
Class Method Details
.canonicalize(view) ⇒ Symbol
19 20 21 |
# File 'lib/card/view.rb', line 19 def self.canonicalize view view.present? ? view.to_sym : nil # error for no view? end |
Instance Method Details
#deep_root? ⇒ true/false
neither view nor format has a parent
72 73 74 |
# File 'lib/card/view.rb', line 72 def deep_root? !parent && !format.parent end |
#next_ancestor ⇒ Card::View
next voo object found tracing ancestry through parent voos and/or parent formats
78 79 80 |
# File 'lib/card/view.rb', line 78 def next_ancestor parent || (format.parent && format.parent.voo) end |
#ok_view ⇒ Symbol
the final view. can be different from @requested_view when there are issues with permissions, recursions, unknown cards, etc.
55 56 57 58 |
# File 'lib/card/view.rb', line 55 def ok_view @ok_view ||= format.ok_view requested_view, [:skip_perms] end |
#process ⇒ rendered view or a stub
handle rendering, including optional visibility, permissions, and caching
39 40 41 42 43 |
# File 'lib/card/view.rb', line 39 def process return if optional? && hide?(requested_view) fetch { yield ok_view } end |
#requested_view ⇒ Symbol
the view to “attempt”. Typically the same as @raw_view, but @raw_view can be overridden, eg for the main view (top view of the main card on a page)
48 49 50 |
# File 'lib/card/view.rb', line 48 def requested_view @requested_view ||= View.canonicalize [:view] end |
#root ⇒ Card::View
61 62 63 |
# File 'lib/card/view.rb', line 61 def root @root = parent ? parent.root : self end |
#root? ⇒ true/false
66 67 68 |
# File 'lib/card/view.rb', line 66 def root? !parent end |