watermarkchurch / wcc-contentful

An alternative to Contentful's contentful.rb ruby client, contentful_model, and contentful_rails gems all in one.
MIT License
2 stars 1 forks source link

Generator should drop model classes in app/models, not lib/ #15

Open gburgett opened 6 years ago

gburgett commented 6 years ago

Currently the menu generator drops files in lib/wcc/contentful/model which reopen the WCC::Contentful::Model::Menu class to add functionality. These ought to be put in app/models as classes which inherit from the WCC::Contentful::Model::x classes. Example:

# app/models/menu_button.rb
class MenuButton < WCC::Contentful::Model::MenuButton
  # Override the "page" link validation, because the content type ID in JTJ
  # for pages has a capital P.
  validate_field :link, :Link, link_to: 'Page'

  ...
end

This is as opposed to the current usage which reopens the class:

# lib/wcc/contentful/model/menu_button.rb
class WCC::Contentful::Model::MenuButton < WCC::Contentful::Model

Potential complications: