Method: Hattr::ClassMethods#hattr

Defined in:
lib/hattr/class_methods.rb

#hattr(field, attribute, opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
25
# File 'lib/hattr/class_methods.rb', line 20

def hattr(field, attribute, opts = {})
  raise ArgumentError, "`#{OPTIONS_STORAGE_KEY}` is reserved" if attribute.to_sym == OPTIONS_STORAGE_KEY

  validate_options(opts, ATTR_OPTIONS)
  store_attribute(field, attribute, ATTR_DEFAULTS.merge(opts))
end