Class: HierarchySnapshot::Configuration
- Inherits:
-
Object
- Object
- HierarchySnapshot::Configuration
- Defined in:
- lib/hierarchy_snapshot/configuration.rb
Instance Method Summary collapse
- #attrs(*args) ⇒ Object
-
#initialize(top = false) ⇒ Configuration
constructor
A new instance of Configuration.
- #many(assoc, &bl) ⇒ Object
- #require_user ⇒ Object
- #require_user? ⇒ Boolean
Constructor Details
#initialize(top = false) ⇒ Configuration
Returns a new instance of Configuration.
3 4 5 |
# File 'lib/hierarchy_snapshot/configuration.rb', line 3 def initialize(top=false) @top = top end |
Instance Method Details
#attrs(*args) ⇒ Object
16 17 18 19 20 |
# File 'lib/hierarchy_snapshot/configuration.rb', line 16 def attrs(*args) @attrs ||= [] @attrs += args.flatten @attrs end |
#many(assoc, &bl) ⇒ Object
22 23 24 25 26 |
# File 'lib/hierarchy_snapshot/configuration.rb', line 22 def many(assoc, &bl) @many ||= {} @many[assoc] = Configuration.new.tap{|c| c.instance_eval(&bl)} unless assoc.nil? @many end |
#require_user ⇒ Object
7 8 9 10 |
# File 'lib/hierarchy_snapshot/configuration.rb', line 7 def require_user raise 'Only valid at top level' unless @top @require_user = true end |
#require_user? ⇒ Boolean
12 13 14 |
# File 'lib/hierarchy_snapshot/configuration.rb', line 12 def require_user? !!@require_user end |