Class: View::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/view/configuration.rb

Overview

The central place for all configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



43
44
45
46
47
48
49
50
51
# File 'lib/view/configuration.rb', line 43

def initialize
  self.guessing_methods       = %w|to_label display_name full_name name title
                                   username login value to_s|
  self.file_methods           = %w|file? mounted_as public_filename|
  self.path_methods           = %w|url mounted_as public_filename|
  self.path_arguments         = []
  self.default_formatter      = :auto
  self.default_list_formatter = :sentence
end

Instance Attribute Details

#default_formatterObject

Which formatter will be used by default. The default is auto, which does all sorts of interesting stuff to see what to do.



24
25
26
# File 'lib/view/configuration.rb', line 24

def default_formatter
  @default_formatter
end

#default_list_formatterObject

The auto formatter will choose this formatter by default when your value is an array (or really, something that responds to each).



28
29
30
# File 'lib/view/configuration.rb', line 28

def default_list_formatter
  @default_list_formatter
end

#file_methodsObject

To determine if something is an uploaded image, it checks to see whether it responds to one of these methods.



12
13
14
# File 'lib/view/configuration.rb', line 12

def file_methods
  @file_methods
end

#guessing_methodsObject

Used by the guess filter, these are the methods used to format an object. It will use the first method that the object responds to.



8
9
10
# File 'lib/view/configuration.rb', line 8

def guessing_methods
  @guessing_methods
end

#path_argumentsObject

You can set a default argument for rendering images, like the style or size of the image. It will be passed to one of the path_methods.



20
21
22
# File 'lib/view/configuration.rb', line 20

def path_arguments
  @path_arguments
end

#path_methodsObject

To show an image, it will use one of these methods to get the src attribute.



16
17
18
# File 'lib/view/configuration.rb', line 16

def path_methods
  @path_methods
end

Instance Method Details

#configure {|config| ... } ⇒ Object

Shorthand for configuring this gem.

Examples:

In config/initializers/view.rb


View.configure do |config|
  config.default_formatter = :self
end

Yields:

  • (config)

    The View module



39
40
41
# File 'lib/view/configuration.rb', line 39

def configure
  yield self
end