Class: Databound::Config

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

Instance Method Summary collapse

Constructor Details

#initialize(block, model) ⇒ Config

Returns a new instance of Config.



3
4
5
6
7
# File 'lib/databound/config.rb', line 3

def initialize(block, model)
  @model = model
  @permit = {}
  instance_eval(&block)
end

Instance Method Details

#columns(*specified_columns) ⇒ Object



9
10
11
# File 'lib/databound/config.rb', line 9

def columns(*specified_columns)
  @columns = specified_columns
end

#dsl(name, value, strict: true, &block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/databound/config.rb', line 25

def dsl(name, value, strict: true, &block)
  @stricts ||= {}
  @stricts[name] = strict

  @dsls ||= {}
  @dsls[name] ||= {}
  @dsls[name][value.to_s] = block
end

#model(specified_model) ⇒ Object

Raises:



13
14
15
16
17
# File 'lib/databound/config.rb', line 13

def model(specified_model)
  raise ConfigError, "Model '#{@model}' already specified" if @model

  @model = specified_model
end

#permit(*methods, &block) ⇒ Object



19
20
21
22
23
# File 'lib/databound/config.rb', line 19

def permit(*methods, &block)
  methods.each do |method|
    @permit[method] = block
  end
end

#read(name) ⇒ Object



34
35
36
# File 'lib/databound/config.rb', line 34

def read(name)
  instance_variable_get("@#{name}")
end