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.
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
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def controller @controller end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def form @form end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def list @list end |
#lock_before_count ⇒ Object (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_options ⇒ Object (readonly)
Returns the value of attribute max_count_options.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def @max_count_options end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def model @model end |
#scope_options ⇒ Object (readonly)
Returns the value of attribute scope_options.
5 6 7 |
# File 'lib/dynamic_scaffold/config.rb', line 5 def @scope_options end |
#title ⇒ Object (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, = 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
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. @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 |