app/models/viewable.rb in rails_admin_cms-0.0.2 vs app/models/viewable.rb in rails_admin_cms-0.0.3

- old
+ new

@@ -19,11 +19,11 @@ after_touch :expire_cache scope :localized, -> { includes(:unique_key).where(unique_keys: { locale: I18n.locale }) } scope :other_locale, ->(locale) { includes(:unique_key).where(unique_keys: { locale: locale }) } - delegate :has_unlocalized_fields?, :unlocalized_fields, :viewable_type, :dashed_name, :underscored_name, to: :class + delegate :has_unlocalized_fields?, :unlocalized_fields, :viewable_type, to: :class end class_methods do def has_unlocalized_fields(*fields) define_singleton_method :unlocalized_fields do @@ -40,24 +40,12 @@ end def viewable_type name end - - def dashed_name - @_dashed_name ||= underscored_name.dasherize - end - - def underscored_name - @_underscored_name ||= name.underscore.gsub('/', '_') - end end - def short_type - viewable_type.demodulize.underscore - end - def list(locale = nil) self.class.includes(:unique_key) .where(unique_keys: { viewable_type: viewable_type, view_path: view_path, name: unique_key_name }) .where(unique_keys: { locale: locale || self.locale }) end @@ -71,19 +59,9 @@ def unique_key_hash(locale = nil) unique_key .slice(:viewable_type, :view_path, :name, :position) .merge(locale: locale || self.locale) - end - - class << self - def models - @_models ||= names.map{ |name| "Viewable::#{name.camelize}" } - end - - def names - @_names ||= CMS.rb_all_names 'app/models/viewable' - end end private def expire_cache