Class: ActionView::TemplateDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/template_details.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Requested

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale, handler, format, variant) ⇒ TemplateDetails

Returns a new instance of TemplateDetails.



35
36
37
38
39
40
# File 'lib/action_view/template_details.rb', line 35

def initialize(locale, handler, format, variant)
  @locale = locale
  @handler = handler
  @format = format
  @variant = variant
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



33
34
35
# File 'lib/action_view/template_details.rb', line 33

def format
  @format
end

#handlerObject (readonly)

Returns the value of attribute handler.



33
34
35
# File 'lib/action_view/template_details.rb', line 33

def handler
  @handler
end

#localeObject (readonly)

Returns the value of attribute locale.



33
34
35
# File 'lib/action_view/template_details.rb', line 33

def locale
  @locale
end

#variantObject (readonly)

Returns the value of attribute variant.



33
34
35
# File 'lib/action_view/template_details.rb', line 33

def variant
  @variant
end

Instance Method Details

#format_or_defaultObject



62
63
64
# File 'lib/action_view/template_details.rb', line 62

def format_or_default
  format || handler_class.try(:default_format)
end

#handler_classObject



58
59
60
# File 'lib/action_view/template_details.rb', line 58

def handler_class
  Template.handler_for_extension(handler)
end

#matches?(requested) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
# File 'lib/action_view/template_details.rb', line 42

def matches?(requested)
  requested.formats_idx[@format] &&
    requested.locale_idx[@locale] &&
    requested.variants_idx[@variant] &&
    requested.handlers_idx[@handler]
end

#sort_key_for(requested) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/action_view/template_details.rb', line 49

def sort_key_for(requested)
  [
    requested.formats_idx[@format],
    requested.locale_idx[@locale],
    requested.variants_idx[@variant],
    requested.handlers_idx[@handler]
  ]
end