Class: HierarchySnapshot::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/hierarchy_snapshot/configuration.rb

Instance Method Summary collapse

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_userObject



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

Returns:

  • (Boolean)


12
13
14
# File 'lib/hierarchy_snapshot/configuration.rb', line 12

def require_user?
  !!@require_user
end