Sha256: 62a0dd3b057a95f05efe11a6306767d250a574d35feeb5f4a9deb0395da3d2e5

Contents?: true

Size: 704 Bytes

Versions: 7

Compression:

Stored size: 704 Bytes

Contents

# -*- encoding : utf-8 -*-
module AbAdmin
  module Concerns
    module Headerable
      extend ActiveSupport::Concern

      included do
        has_one :header, :as => :headerable, :dependent => :delete

        attr_accessible :header_attributes

        accepts_nested_attributes_for :header, :reject_if => :all_blank

        ::Header.all_translated_attribute_names.each do |attr|
          define_method "header_#{attr}=" do |val|
            default_header.send("#{attr}=", val)
          end

          define_method "header_#{attr}" do
            default_header.send(attr)
          end
        end
      end

      def default_header
        header || build_header
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.2.3 lib/ab_admin/concerns/headerable.rb
ab_admin-0.2.2 lib/ab_admin/concerns/headerable.rb
ab_admin-0.2.1 lib/ab_admin/concerns/headerable.rb
ab_admin-0.2.0 lib/ab_admin/concerns/headerable.rb
ab_admin-0.1.2 lib/ab_admin/concerns/headerable.rb
ab_admin-0.1.1 lib/ab_admin/concerns/headerable.rb
ab_admin-0.1.0 lib/ab_admin/concerns/headerable.rb