Module: NaturalBornSlugger::ClassMethods
- Defined in:
- lib/natural_born_slugger/class_methods.rb
Instance Method Summary collapse
-
#has_composite_attribute(name, options = {}) ⇒ Object
Adds a generic composite attribute to the class.
-
#has_natural_key(name, options = {}) ⇒ Object
Adds a natural key to the class.
-
#has_slug(name, options = {}) ⇒ Object
Adds a slug to the class.
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, ={}) NaturalBornSlugger::AttributeComposer.new(name, ).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, ={}) # Use default name if not provided name, = 'natural_key', name if name.is_a?(Hash) NaturalBornSlugger::AttributeComposer.new(name, ).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, ={}) # Use default name if not provided name, = 'slug', name if name.is_a?(Hash) NaturalBornSlugger::AttributeComposer.new(name, ).add_to(self) end |