Sha256: 1868ca161f9b9e94aa461b11bdb7c7cadddacfd4a29638fed21c764485d604b1

Contents?: true

Size: 697 Bytes

Versions: 9

Compression:

Stored size: 697 Bytes

Contents

# encoding: utf-8
module Sunrise
  module Models
    module Header
      def self.included(base)
        base.send :include, InstanceMethods
        base.send :extend,  ClassMethods
      end
      
      module ClassMethods
        def self.extended(base)
          base.class_eval do
            belongs_to :headerable, :polymorphic => true
          end
        end
      end
      
      module InstanceMethods
        def empty?
          [keywords, description, title].map(&:blank?).all?
        end

        def has_info?
          !empty?
        end

        def read(key)
          value = read_attribute(key)
          value.blank? ? nil : value
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/models/header.rb
sunrise-core-0.2.1 lib/sunrise/models/header.rb
sunrise-core-0.2.0 lib/sunrise/models/header.rb
sunrise-core-0.1.5 lib/sunrise/models/header.rb
sunrise-core-0.1.4 lib/sunrise/models/header.rb
sunrise-core-0.1.3 lib/sunrise/models/header.rb
sunrise-core-0.1.2 lib/sunrise/models/header.rb
sunrise-core-0.1.1 lib/sunrise/models/header.rb
sunrise-core-0.1.0 lib/sunrise/models/header.rb