nofxx/symbolize — Issue #17: Already defined scopes will be overwritten
Author: asaaki
Created: 2011-10-23 03:49:19+00:00
State: open

Would be nice, if following definition will throw an exception or a warning:

(only tested with mongoid)

```ruby
symbolize :foo, :in => [:one, :two, :three], :scopes => true
symbolize :bar, :in => [:two, :three, :four], :scopes => true
```

results in:

```ruby
MyModel.two
=> #:two},
options: {},
class: MyModel,
embedded: false>
```

Currently the latest definition will overwrite any existing scopes of previous defintions.

I think for symbolize it's more important than in general/origin scope handling of the ORMs where you have to write every scope manually and also can avoid naming conflicts like in this example above (of course, also a general warning while trying to overwrite a defined scope would be nice, but should be a concern of the ORMs then).

The exception could be something like this:

```ruby
symbolize :foo, :in => [:one, :two, :three], :scopes => true
symbolize :bar, :in => [:two, :three, :four], :scopes => true

# => throws:
Symbolize::DuplicateScopesError: duplicate scope definition of **scope** in **model** at **file:line**
```

Something like the warning if somebody tries to redefine a constant. ;o)

Mongoid should be warn, but it seems that they have a tiny mistake avoiding a log message.
I've reported this: https://github.com/mongoid/mongoid/issues/1373

If and when they will fix this and also implement my requested exception option, this issue will become obsolete.

----

This issue seems to be a *solve first* dependency of issue #16.