class Declarative::Heritage
Public Instance Methods
call(inheritor, &block)
click to toggle source
Replay the recorded assignments on inheritor. Accepts a block that will allow processing the arguments for every recorded statement.
# File lib/declarative/heritage.rb, line 12 def call(inheritor, &block) each { |cfg| call!(inheritor, cfg, &block) } end
record(method, *args, &block)
click to toggle source
Record inheritable assignments for replay in an inheriting class.
# File lib/declarative/heritage.rb, line 6 def record(method, *args, &block) self << {method: method, args: DeepDup.(args), block: block} # DISCUSS: options.dup. end
Private Instance Methods
call!(inheritor, cfg) { |cfg| ... }
click to toggle source
# File lib/declarative/heritage.rb, line 39 def call!(inheritor, cfg) yield cfg if block_given? # allow messing around with recorded arguments. inheritor.send(cfg[:method], *cfg[:args], &cfg[:block]) end