Module: BallGag::ClassMethods

Defined in:
lib/ball_gag/gag.rb

Instance Method Summary collapse

Instance Method Details

#clear_gagged_attributesObject



35
36
37
# File 'lib/ball_gag/gag.rb', line 35

def clear_gagged_attributes
  undefine_gagged_attributes_methods
end

#gag(*arguments, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ball_gag/gag.rb', line 16

def gag *arguments, &block
  define_and_mixin_gagged_attributes_methods

  callable = arguments.pop if arguments.last.respond_to? :call
  options = arguments.pop if arguments.last.kind_of? Hash

  to_call = callable || block || BallGag.engine ||
    lambda { |*| raise NoEngineConfiguredError }

  define_not_gagged_interpellations(arguments, to_call, options)

  arguments.each do |attribute|
    @gagged_attributes[attribute] = to_call
    define_gagged_interpellation attribute
  end

  arguments
end

#gagged_attributesObject



11
12
13
14
# File 'lib/ball_gag/gag.rb', line 11

def gagged_attributes
  clear_gagged_attributes unless @gagged_attributes
  @gagged_attributes.keys
end