Sha256: 81be165cf019b5c8ee6f746443449323b9a14939eab41485acbbf27c217119b4

Contents?: true

Size: 853 Bytes

Versions: 28

Compression:

Stored size: 853 Bytes

Contents

require 'sunrise/config/field'
require 'sunrise/config/nested_field'

module Sunrise
  module Config
    # Provides accessors and autoregistering of model's fields.
    module HasFields
    
      # Array for store all defined fields
      def fields
        @fields ||= []
      end
      
      # Defines a configuration for a field.
      def field(name, options = {})
        options = { :name => name.to_sym }.merge(options)
        fields << Field.new(abstract_model, self, options)
      end

      # Defines a configuration for a nested attributes
      def nested_attributes(name, options = {}, &block)
        options = { :name => name.to_sym }.merge(options)
        nested_field = NestedField.new(abstract_model, self, options)
        nested_field.instance_eval &block if block
        fields << nested_field
      end
    end
  end
end   

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sunrise-cms-1.0.0 lib/sunrise/config/has_fields.rb
sunrise-cms-1.0.0.rc3 lib/sunrise/config/has_fields.rb
sunrise-cms-1.0.0.rc2 lib/sunrise/config/has_fields.rb
sunrise-cms-1.0.0.rc1 lib/sunrise/config/has_fields.rb
sunrise-cms-0.7.0.rc2 lib/sunrise/config/has_fields.rb
sunrise-cms-0.7.0.rc1 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.11 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.10 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.9 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.8 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.7 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.6 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.5 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.4 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.3 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.2 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.1 lib/sunrise/config/has_fields.rb
sunrise-cms-0.6.0 lib/sunrise/config/has_fields.rb
sunrise-cms-0.5.3 lib/sunrise/config/has_fields.rb
sunrise-cms-0.5.2 lib/sunrise/config/has_fields.rb