Sha256: dbabca8a37e3558e33cff5cbd7e2efeb71c5bc9819ba3f71d14f047043c84f2f

Contents?: true

Size: 694 Bytes

Versions: 7

Compression:

Stored size: 694 Bytes

Contents

# encoding: UTF-8

module Spontaneous::Plugins
  module SchemaTitle
    extend ActiveSupport::Concern

    module ClassMethods
      def class_name_with_fallback
        n = name
        if n.nil? or n.empty?
          n = "ContentClass#{object_id}"
        end
        n
      end

      def title(custom_title=nil)
        self.title = custom_title if custom_title
        @title or default_title
      end

      def default_title
        n = class_name_with_fallback.split(/::/).last.gsub(/([A-Z]+)([A-Z][a-z])/,'\1 \2')
        n.gsub!(/([a-z\d])([A-Z])/,'\1 \2')
        n
      end

      def title=(title)
        @title = title
      end
    end # ClassMethods
  end # SchemaTitle
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spontaneous-0.2.0.alpha7 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha6 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha5 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha4 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha3 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha2 lib/spontaneous/plugins/schema_title.rb
spontaneous-0.2.0.alpha1 lib/spontaneous/plugins/schema_title.rb