Sha256: 015682e4286e7bb91175c6049c93a5919f22d87812ee473a4672495ce4ee1337

Contents?: true

Size: 695 Bytes

Versions: 11

Compression:

Stored size: 695 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

11 entries across 11 versions & 1 rubygems

Version Path
ab_admin-0.6.1 lib/ab_admin/concerns/headerable.rb
ab_admin-0.6.0 lib/ab_admin/concerns/headerable.rb
ab_admin-0.5.0 lib/ab_admin/concerns/headerable.rb
ab_admin-0.4.0 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.6 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.5 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.4 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.3 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.2 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.1 lib/ab_admin/concerns/headerable.rb
ab_admin-0.3.0 lib/ab_admin/concerns/headerable.rb