joshuabowers / opium

An Object Parse.com Mapping technology for defining models.
MIT License
1 stars 0 forks source link

Provide configuration options for mapping model name to parse class name #13

Open joshuabowers opened 9 years ago

joshuabowers commented 9 years ago

Currently, this is just pulling model_class.model_name.name and then demodulizing it. Conceptually, it might be useful to have a (yml-based) config setting for class_name_map_func which, if set, would be to_proc'd; default would be demodulize. This could then be invoked from #resource_name to get the proper version of the name.

As a nice extension to this, when configuring Opium via ruby would likely allow for the following without any extra effort within #resource_name:

Opium.configure do |config|
  # Take the first character from each module and mash them as a prefix
  config.class_name_map_func = ->( name ) { name.split('::')[0..-2].map {|n| n[0]}.join + name.demodulize }
end