Class: GoldenFleece::Context

Inherits:
Object
  • Object
show all
Includes:
Export, Formats, Getters, Normalizers, Schemas
Defined in:
lib/golden_fleece/context.rb,
lib/golden_fleece/context/export.rb,
lib/golden_fleece/context/formats.rb,
lib/golden_fleece/context/getters.rb,
lib/golden_fleece/context/schemas.rb,
lib/golden_fleece/context/normalizers.rb

Defined Under Namespace

Modules: Export, Formats, Getters, Normalizers, Schemas

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Schemas

#define_schemas

Methods included from Normalizers

#define_normalizers

Methods included from Getters

#define_getters

Methods included from Formats

#define_formats

Methods included from Export

#export

Constructor Details

#initialize(model_class) ⇒ Context

Returns a new instance of Context.



19
20
21
22
23
24
25
26
27
# File 'lib/golden_fleece/context.rb', line 19

def initialize(model_class)
  @model_class = model_class
  @normalizers = {}
  @formats = {}
  @attributes = []
  @schemas = Schema.new(self, '/', {})
  @setup_callbacks = []
  @has_run_setup = false
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def attributes
  @attributes
end

#formatsObject (readonly)

Returns the value of attribute formats.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def formats
  @formats
end

#has_run_setupObject (readonly)

Returns the value of attribute has_run_setup.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def has_run_setup
  @has_run_setup
end

#model_classObject (readonly)

Returns the value of attribute model_class.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def model_class
  @model_class
end

#normalizersObject (readonly)

Returns the value of attribute normalizers.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def normalizers
  @normalizers
end

#rulesObject

Returns the value of attribute rules.



16
17
18
# File 'lib/golden_fleece/context.rb', line 16

def rules
  @rules
end

#schemasObject (readonly)

Returns the value of attribute schemas.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def schemas
  @schemas
end

#setup_callbacksObject (readonly)

Returns the value of attribute setup_callbacks.



17
18
19
# File 'lib/golden_fleece/context.rb', line 17

def setup_callbacks
  @setup_callbacks
end

Instance Method Details

#run_setup_callbacksObject



29
30
31
32
33
34
35
# File 'lib/golden_fleece/context.rb', line 29

def run_setup_callbacks
  @setup_callbacks.each do |cb|
    cb.call self
  end

  @has_run_setup = true
end