Class: Card::View
- Inherits:
-
Object
- Object
- Card::View
- Extended by:
- Cache::ClassMethods
- Includes:
- Cache, Fetch, Options, Stub, Visibility
- Defined in:
- lib/card/view.rb,
lib/card/view/stub.rb,
lib/card/view/cache.rb,
lib/card/view/fetch.rb,
lib/card/view/options.rb,
lib/card/view/visibility.rb
Defined Under Namespace
Modules: Cache, Fetch, Options, Stub, Visibility
Constant Summary
Constants included from Fetch
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
-
#initialize(format, view, raw_options = {}, parent = nil) ⇒ View
constructor
A new instance of View.
-
#ok_view ⇒ Object
the final view.
-
#process ⇒ Object
handle rendering, including optional visibility, permissions, and caching.
-
#requested_view ⇒ Object
the view to "attempt".
Methods included from Cache::ClassMethods
Methods included from Options
accessible_keys, all_keys, #closest_live_option, define_getter, define_setter, heir_keys, #items, #live_options, nest_keys, #normalize_cache, #normalize_editor, #slot_options
Methods included from Stub
#stub, #stub_hash, #stub_json, #validate_stub
Methods included from Cache
#cache_fetch, #cache_key, #caching, #caching?, #deep_root?, #hash_for_cache_key, #option_for_cache_key, #options_for_cache_key, #root
Methods included from Fetch
#cache_setting, #clean_enough_to_cache?, #dependent_cache_level, #dependent_cache_level_unvalidated, #dependent_cache_ok?, #dependent_cache_setting, #dependent_cacheable_permissible?, #determine_cache_level, #fetch, #independent_cache_level, #independent_cache_ok?, #permission_task, #with_fetch_logging
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.
24 25 26 27 28 29 30 31 32 |
# File 'lib/card/view.rb', line 24 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) ⇒ Object
19 20 21 22 |
# File 'lib/card/view.rb', line 19 def self.canonicalize view return if view.blank? # error? view.to_viewname.key.to_sym end |
Instance Method Details
#ok_view ⇒ Object
the final view. can be different from @requested_view when there are issues with permissions, recursions, unknown cards, etc.
50 51 52 53 |
# File 'lib/card/view.rb', line 50 def ok_view @ok_view ||= format.ok_view requested_view, [:skip_perms] end |
#process ⇒ Object
handle rendering, including optional visibility, permissions, and caching
35 36 37 38 39 40 |
# File 'lib/card/view.rb', line 35 def process return if optional? && hide?(requested_view) fetch { yield ok_view, } end |
#requested_view ⇒ Object
the view to "attempt". Typically the same as @raw_view, but @raw_view is often overridden for the main view (top view of the main card on a page)
44 45 46 |
# File 'lib/card/view.rb', line 44 def requested_view @requested_view ||= View.canonicalize [:view] end |