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