Sha256: 9890ee827ecdcde8d9ab14fc05e5c5c9ac1959da4ec2fcfd7933e73ea157792c

Contents?: true

Size: 635 Bytes

Versions: 9

Compression:

Stored size: 635 Bytes

Contents

module Fiveruns::Dash
  
  module Typable
    
    def self.included(base)
      name = Fiveruns::Dash::Util.shortname(base.name)
      base.class_eval %{
        def self.#{name}_type
          @#{name}_type ||= begin
            short = Fiveruns::Dash::Util.shortname(name)
            short.sub(/_#{name}$/, '').to_sym
          end
        end
      }
      base.extend ClassMethods
    end
    
    module ClassMethods
      
      def inherited(klass)
        types[klass.__send__("#{Fiveruns::Dash::Util.shortname(name)}_type")] = klass
      end

      def types
        @types ||= {}
      end
      
    end
    
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fiveruns-dash-ruby-0.8.0 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.1 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.10 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.3 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.4 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.5 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.6 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.8 lib/fiveruns/dash/typable.rb
fiveruns-dash-ruby-0.8.9 lib/fiveruns/dash/typable.rb