Sha256: af022e267207eaa6f6da43d43fb9ad411a84e5c9447ce30544ca9f24398f475b

Contents?: true

Size: 616 Bytes

Versions: 3

Compression:

Stored size: 616 Bytes

Contents

# encoding: utf-8
module Freeberry
  module HeaderUtils
    def self.included(base)
      base.send(:extend, ClassMethods)
      base.send(:include, InstanceMethods)
    end
    
    module ClassMethods
      def self.extended(base)
        base.class_eval do
          has_one :header, :as => :headerable, :dependent => :delete
          
          attr_accessible :header_attributes
          
          accepts_nested_attributes_for :header, :reject_if => :all_blank
        end
      end
    end
    
    module InstanceMethods
      def default_header
        header || build_header
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freeberry-0.3.0 lib/freeberry/header_utils.rb
freeberry-0.2.9 lib/freeberry/header_utils.rb
freeberry-0.2.7 lib/freeberry/header_utils.rb