Sha256: 23cd4cd5b63eb616c2aeb538678c89127cad4b1ffc6d793b7c427bce8ec408d9

Contents?: true

Size: 974 Bytes

Versions: 15

Compression:

Stored size: 974 Bytes

Contents

module Gluttonberg
  module Content
    # The mixin used when generating a localization for content classes. It
    # adds the base properties — e.g. id — and associations. It also comes with
    # some convenience methods for accessing the associated section in a page.
    # 
    # These just defer to the parent class.
    module BlockLocalization
      def self.included(klass)
        klass.class_eval do
          class << self; attr_accessor :content_type, :association_name end
          
          belongs_to :page_localization
        end
      end
      
      def association_name
        self.class.association_name
      end
      
      def content_type
        self.class.content_type
      end
      
      def section_name
        parent.section[:name]
      end
      
      def section_position
        parent.section[:position]
      end
      
      def section_label
        parent.section[:label] unless parent.blank?
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gluttonberg-core-2.6.4 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.6.3 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.6.2 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.6.1 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.6.0 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.9 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.8 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.7 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.6 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.5 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.4 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.3 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.2 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5.1 lib/gluttonberg/content/block_localization.rb
gluttonberg-core-2.5 lib/gluttonberg/content/block_localization.rb