Module: NaturalBornSlugger::ClassMethods

Defined in:
lib/natural_born_slugger/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#has_composite_attribute(name, options = {}) ⇒ Object

Adds a generic composite attribute to the class. Name is required.



27
28
29
# File 'lib/natural_born_slugger/class_methods.rb', line 27

def has_composite_attribute(name, options={})
  NaturalBornSlugger::AttributeComposer.new(name, options).add_to(self)
end

#has_natural_key(name, options = {}) ⇒ Object

Adds a natural key to the class. Name is optional.



18
19
20
21
22
# File 'lib/natural_born_slugger/class_methods.rb', line 18

def has_natural_key(name, options={})
  # Use default name if not provided
  name, options = 'natural_key', name if name.is_a?(Hash)
  NaturalBornSlugger::AttributeComposer.new(name, options).add_to(self)
end

#has_slug(name, options = {}) ⇒ Object

Adds a slug to the class. Name is optional.



9
10
11
12
13
# File 'lib/natural_born_slugger/class_methods.rb', line 9

def has_slug(name, options={})
  # Use default name if not provided
  name, options = 'slug', name if name.is_a?(Hash)
  NaturalBornSlugger::AttributeComposer.new(name, options).add_to(self)
end