Class: DynamicScaffold::Config
- Inherits:
-
Object
- Object
- DynamicScaffold::Config
- Defined in:
- lib/dynamic_scaffold/config.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#lock_before_count ⇒ Object
readonly
Returns the value of attribute lock_before_count.
-
#max_count_options ⇒ Object
readonly
Returns the value of attribute max_count_options.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#scope_options ⇒ Object
readonly
Returns the value of attribute scope_options.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(model, controller) ⇒ Config
constructor
A new instance of Config.
- #max_count(count = nil, options = nil, &block) ⇒ Object
- #max_count?(count) ⇒ Boolean
- #scope(*args) ⇒ Object
- #vars(name = nil, &block) ⇒ Object
Constructor Details
#initialize(model, controller) ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 20 21 |
# File 'lib/dynamic_scaffold/config.rb', line 13 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
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def controller @controller end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def form @form end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def list @list end |
#lock_before_count ⇒ Object (readonly)
Returns the value of attribute lock_before_count.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def lock_before_count @lock_before_count end |
#max_count_options ⇒ Object (readonly)
Returns the value of attribute max_count_options.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def @max_count_options end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def model @model end |
#scope_options ⇒ Object (readonly)
Returns the value of attribute scope_options.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def @scope_options end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/dynamic_scaffold/config.rb', line 3 def title @title end |
Instance Method Details
#max_count(count = nil, options = nil, &block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/dynamic_scaffold/config.rb', line 41 def max_count(count = nil, = nil, &block) @max_count = count unless count.nil? @max_count_options = unless .nil? @lock_before_count = block if block_given? @max_count end |
#max_count?(count) ⇒ Boolean
48 49 50 51 52 |
# File 'lib/dynamic_scaffold/config.rb', line 48 def max_count?(count) return false if max_count.nil? count >= max_count end |
#scope(*args) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/dynamic_scaffold/config.rb', line 33 def scope(*args) if args.present? @scope_options = args. @scope = args[0] end @scope end |
#vars(name = nil, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/dynamic_scaffold/config.rb', line 23 def vars(name = nil, &block) if block_given? raise ArgumentError, 'Missing var name.' if name.nil? @vars._register(name, block) else @vars end end |