Sha256: 8ef68fb24a3e1e92bb214ca0ddd0149b1927dbf15ddea04d30b997e482111707

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

# encoding: utf-8
module Freeberry
  module HeaderTools
    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
          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

1 entries across 1 versions & 1 rubygems

Version Path
freeberry-0.2.6 lib/freeberry/header_tools.rb