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.



132
133
134
135
136
137
138
139
140
# File 'lib/dynamic_scaffold/config.rb', line 132

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.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def controller
  @controller
end

#formObject (readonly)

Returns the value of attribute form.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def form
  @form
end

#listObject (readonly)

Returns the value of attribute list.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def list
  @list
end

#lock_before_countObject (readonly)

Returns the value of attribute lock_before_count.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def lock_before_count
  @lock_before_count
end

#max_count_optionsObject (readonly)

Returns the value of attribute max_count_options.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def max_count_options
  @max_count_options
end

#modelObject (readonly)

Returns the value of attribute model.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def model
  @model
end

#scope_optionsObject (readonly)

Returns the value of attribute scope_options.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def scope_options
  @scope_options
end

#titleObject (readonly)

Returns the value of attribute title.



122
123
124
# File 'lib/dynamic_scaffold/config.rb', line 122

def title
  @title
end

Instance Method Details

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



159
160
161
162
163
164
# File 'lib/dynamic_scaffold/config.rb', line 159

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)


166
167
168
169
# File 'lib/dynamic_scaffold/config.rb', line 166

def max_count?(count)
  return false if max_count.nil?
  count >= max_count
end

#scope(*args) ⇒ Object



151
152
153
154
155
156
157
# File 'lib/dynamic_scaffold/config.rb', line 151

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

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



142
143
144
145
146
147
148
149
# File 'lib/dynamic_scaffold/config.rb', line 142

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