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
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.
-
#unsupported_view ⇒ Object
Returns the value of attribute unsupported_view.
Attributes included from Options
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, #validate_active_cache_action
Methods included from Options
accessible_keys, all_keys, carditect_keys, #closest_live_option, define_getter, define_setter, heir_keys, #items, #live_options, #normalize_cache, #normalize_editor, #slot_options
Methods included from Stub
escape, #invalid_stub, #reject_foreign_options_in_stub!, #stub, #stub_hash, #stub_json, unescape, #validate_stub!, #with_override
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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/card/view.rb', line 28 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 |
#unsupported_view ⇒ Object
Returns the value of attribute unsupported_view.
17 18 19 |
# File 'lib/card/view.rb', line 17 def unsupported_view @unsupported_view end |
Class Method Details
.canonicalize(view) ⇒ Symbol
20 21 22 |
# File 'lib/card/view.rb', line 20 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
73 74 75 |
# File 'lib/card/view.rb', line 73 def deep_root? !parent && !format.parent end |
#next_ancestor ⇒ Card::View
next voo object found tracing ancestry through parent voos and/or parent formats
79 80 81 |
# File 'lib/card/view.rb', line 79 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.
56 57 58 59 |
# File 'lib/card/view.rb', line 56 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
40 41 42 43 44 |
# File 'lib/card/view.rb', line 40 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)
49 50 51 |
# File 'lib/card/view.rb', line 49 def requested_view @requested_view ||= View.canonicalize [:view] end |
#root ⇒ Card::View
62 63 64 |
# File 'lib/card/view.rb', line 62 def root @root = parent ? parent.root : self end |
#root? ⇒ true/false
67 68 69 |
# File 'lib/card/view.rb', line 67 def root? !parent end |