Sha256: 006e35866ee5eae38ad813bbd2a2ea975fdb0fc2901d4b2aa25aab907d727091
Contents?: true
Size: 890 Bytes
Versions: 2
Compression:
Stored size: 890 Bytes
Contents
# frozen_string_literal: true 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 = :custom, options = {}, &block) options = { name: name.to_sym }.merge(options) fields << Field.new(abstract_model, self, options, &block) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sunrise-cms-1.1.1 | lib/sunrise/config/has_fields.rb |
sunrise-cms-1.1.0 | lib/sunrise/config/has_fields.rb |