Sha256: 596265db44aa5217eddc2a4e75122292133d1bd54a793f99c1ac0e2a9e7e6d01
Contents?: true
Size: 1.25 KB
Versions: 12
Compression:
Stored size: 1.25 KB
Contents
require "active_support/concern" module BitPlayer module ContentProviders # Presentation logic for a "show" or "index" view on a data model. module ViewProvider extend ActiveSupport::Concern included do def self.data_class(klass) @source_class = klass end def self.source_class @source_class || fail("Classes inheriting from #{ self } must define a source class with `data_class <class>`") end def self.show_nav_link @show_nav_link = true end def self.hide_nav_link @show_nav_link = false end def self.show_nav_link? @show_nav_link end def self.view_type(type) unless ["show", "index"].include?(type) fail("view type must be one of 'show', 'index'") end @view_type = type end def self.get_view_type @view_type end end def show_nav_link? self.class.show_nav_link? end def template "#{ plural_name }/#{ self.class.get_view_type }" end private def plural_name self.class.source_class.to_s.underscore.pluralize end end end end
Version data entries
12 entries across 12 versions & 1 rubygems