Sha256: d63e56acedbd5ec2119fab0c432148fd75c397c9f79fd535c6059360a42ac197

Contents?: true

Size: 404 Bytes

Versions: 5

Compression:

Stored size: 404 Bytes

Contents

module Storefront
  module ModelHelper
    def self.included(base)
      base.class_eval do
        def self.to_title
          name
        end unless self.respond_to?(:to_title)
        
        def to_title
          return title if respond_to?(:title)
          return name if respond_to?(:name)
          to_s
        end unless self.instance_methods.include?(:to_title)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storefront-0.3.2 lib/storefront/model_helper.rb
storefront-0.3.1 lib/storefront/model_helper.rb
storefront-0.3.0 lib/storefront/model_helper.rb
storefront-0.2.8 lib/storefront/model_helper.rb
storefront-0.2.7 lib/storefront/model_helper.rb