module Sunrise::Config::HasFields

Provides accessors and autoregistering of model's fields.

Public Instance Methods

field(name = :custom, options = {}, &block) click to toggle source

Defines a configuration for a field.

# File lib/sunrise/config/has_fields.rb, line 16
def field(name = :custom, options = {}, &block)
  options = { name: name.to_sym }.merge(options)
  fields << Field.new(abstract_model, self, options, &block)
end
fields() click to toggle source

Array for store all defined fields

# File lib/sunrise/config/has_fields.rb, line 11
def fields
  @fields ||= []
end
nested_attributes(name, options = {}, &block) click to toggle source

Defines a configuration for a nested attributes

# File lib/sunrise/config/has_fields.rb, line 22
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