Sha256: 6856a83e72cfd2eab8f343ac9a76530a93c7dd9c8600a29dcd11c09e780d24b1

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

##
# Identifier
#
# Some unique keys which can be used for routing
# and APIs
module Outpost
  module Model
    module Identifier
      extend ActiveSupport::Concern

      
      module ClassMethods
        def content_key
          if self.respond_to? :table_name
            self.table_name.gsub(/_/, "/")
          else
            self.name.tableize
          end
        end
        
        # Wrappers for ActiveModel::Naming
        # NewsStory => news_stories
        def route_key
          ActiveModel::Naming.route_key(self)
        end
        
        # NewsStory => news_story
        def singular_route_key
          ActiveModel::Naming.singular_route_key(self)
        end
      end
      
      # Default obj_key pattern
      def obj_key
        @obj_key ||= [self.class.content_key,self.id || "new"].join(":")
      end
    end # Identifier
  end # Model
end # Outpost

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 lib/outpost/model/identifier.rb