Class: Components::Base

Inherits:
Object
  • Object
show all
Includes:
ActionController::Helpers, ActionController::UrlWriter, Caching
Defined in:
lib/components/base.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Caching

included

Class Attribute Details

.templateObject

Returns the value of attribute template.



32
33
34
# File 'lib/components/base.rb', line 32

def template
  @template
end

Instance Attribute Details

#_requestObject

for request forgery protection compatibility



8
9
10
# File 'lib/components/base.rb', line 8

def _request
  @_request
end

#form_authenticity_tokenObject

for request forgery protection compatibility



8
9
10
# File 'lib/components/base.rb', line 8

def form_authenticity_token
  @form_authenticity_token
end

Class Method Details

.pathObject Also known as: controller_path

:nodoc:



27
28
29
# File 'lib/components/base.rb', line 27

def path #:nodoc:
  @path ||= self.to_s.sub("Component", "").underscore
end

.view_pathsObject

The view paths to search for templates. Typically this will only be “app/components”, but if you have a plugin that uses Components, it may add its own directory (e.g. “vendor/plugins/scaffolding/components/” to this array.



19
20
21
22
23
24
25
# File 'lib/components/base.rb', line 19

def view_paths
  if read_inheritable_attribute(:view_paths).nil?
    default_path = File.join(RAILS_ROOT, 'app', 'components')
    write_inheritable_attribute(:view_paths, [default_path])
  end
  read_inheritable_attribute(:view_paths)
end

Instance Method Details

#loggerObject

must be public for access from ActionView



36
37
38
# File 'lib/components/base.rb', line 36

def logger #:nodoc:
  RAILS_DEFAULT_LOGGER
end

#protect_against_forgery?Boolean

:nodoc:



11
12
13
# File 'lib/components/base.rb', line 11

def protect_against_forgery? #:nodoc:
  allow_forgery_protection && request_forgery_protection_token
end