Class: DynamicScaffold::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, controller) ⇒ Config

Returns a new instance of Config.



15
16
17
18
19
20
21
22
23
# File 'lib/dynamic_scaffold/config.rb', line 15

def initialize(model, controller)
  @model = model
  @controller = controller
  @form = FormBuilder.new(self)
  @list = ListBuilder.new(self)
  @title = Title.new(self)
  @vars = Vars.new(self)
  @max_count_options = {}
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def controller
  @controller
end

#formObject (readonly)

Returns the value of attribute form.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def form
  @form
end

#listObject (readonly)

Returns the value of attribute list.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def list
  @list
end

#lock_before_countObject (readonly)

Returns the value of attribute lock_before_count.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def lock_before_count
  @lock_before_count
end

#max_count_optionsObject (readonly)

Returns the value of attribute max_count_options.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def max_count_options
  @max_count_options
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def model
  @model
end

#scope_optionsObject (readonly)

Returns the value of attribute scope_options.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def scope_options
  @scope_options
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/dynamic_scaffold/config.rb', line 5

def title
  @title
end

Instance Method Details

#max_count(count = nil, options = nil, &block) ⇒ Object



43
44
45
46
47
48
# File 'lib/dynamic_scaffold/config.rb', line 43

def max_count(count = nil, options = nil, &block)
  @max_count = count unless count.nil?
  @max_count_options = options unless options.nil?
  @lock_before_count = block if block_given?
  @max_count
end

#max_count?(count) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
# File 'lib/dynamic_scaffold/config.rb', line 50

def max_count?(count)
  return false if max_count.nil?

  count >= max_count
end

#scope(*args) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/dynamic_scaffold/config.rb', line 35

def scope(*args)
  if args.present?
    @scope_options = args.extract_options!
    @scope = args[0]
  end
  @scope
end

#vars(name = nil, &block) ⇒ Object



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

def vars(name = nil, &block)
  if block_given?
    raise ArgumentError, 'Missing var name.' if name.nil?

    @vars._register(name, block)
  else
    @vars
  end
end