Class: Filtrum::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/filtrum/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, options = {}, &block) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/filtrum/config.rb', line 6

def initialize model, options = {}, &block

  @model = model
  @views = []

  @settings = Settings.new Filtrum.settings
  extend @settings.dsl

  instance_eval &block if block
  @frozen = true
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/filtrum/config.rb', line 4

def model
  @model
end

#settingsObject (readonly)

Returns the value of attribute settings.



4
5
6
# File 'lib/filtrum/config.rb', line 4

def settings
  @settings
end

Instance Method Details

#default_view(options = {}, &block) ⇒ Object



24
25
26
# File 'lib/filtrum/config.rb', line 24

def default_view options = {}, &block
  view :default, options, &block
end

#process(params) ⇒ Object

Raises:



28
29
30
31
# File 'lib/filtrum/config.rb', line 28

def process params
  raise ConfigurationError, "You must specify a default view" unless view(:default)
  view(:default).process params
end

#view(name, options = {}, &block) ⇒ Object



18
19
20
21
22
# File 'lib/filtrum/config.rb', line 18

def view name, options = {}, &block
  return @views.find{ |v| v.name.to_s == name.to_s } if @frozen
  @views.delete_if{ |v| v.name.to_s == name }
  View.new(name, self, options, &block).tap{ |v| @views << v }
end