Module: Hefted::ClassMethod

Defined in:
lib/hefted/class_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#heftsObject (readonly)

Returns the value of attribute hefts.



11
12
13
# File 'lib/hefted/class_method.rb', line 11

def hefts
  @hefts
end

Instance Method Details

#hefted(**args) ⇒ Object



5
6
7
8
9
10
# File 'lib/hefted/class_method.rb', line 5

def hefted(**args)
  arguments = const_join(args)
  template = Base.new(*arguments.keys)
  self.const_set(arguments.name, template.new(*arguments.values).freeze)
  @hefts = (@hefts.nil? ? [] : @hefts) << arguments.name
end

#release_hefted(*names) ⇒ Object



13
14
15
16
17
# File 'lib/hefted/class_method.rb', line 13

def release_hefted(*names)
  names.each do |name|
    remove_const(name.to_camel) if const_defined?(name.to_camel)
  end
end