Module: SiteHub::Collection::ClassMethods
- Defined in:
- lib/sitehub/collection.rb
Constant Summary collapse
- UNIQUE_LABELS_MSG =
'supply unique labels'.freeze
Instance Method Summary collapse
Instance Method Details
#method_added(name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sitehub/collection.rb', line 13 def method_added(name) if name == :add && !overrides.include?(name) overrides << name alias_method :add_backup, :add send(:define_method, :add) do |id, value, *args| raise DuplicateVersionException, UNIQUE_LABELS_MSG if self[id] add_backup id, value, *args end end end |
#overrides ⇒ Object
7 8 9 |
# File 'lib/sitehub/collection.rb', line 7 def overrides @overrides ||= [] end |