Class: CFF::ModelPart

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/cff/model_part.rb

Overview

ModelPart is the superclass of anything that makes up part of the CFF Model. This includes Model, Person, Entity and Reference.

ModelPart does not provide any methods or fields for the public API.

Direct Known Subclasses

Entity, Model, Person, Reference

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#build_actor_collection!, #fields_to_hash, #method_to_field, #normalize_modelpart_array!

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/cff/model_part.rb', line 29

def method_missing(name, *args)
  n = method_to_field(name.id2name)
  super unless self.class::ALLOWED_FIELDS.include?(n.chomp('='))

  if n.end_with?('=')
    @fields[n.chomp('=')] = args[0] || ''
  else
    @fields[n]
  end
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



27
28
29
# File 'lib/cff/model_part.rb', line 27

def fields
  @fields
end

Instance Method Details

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/cff/model_part.rb', line 40

def respond_to_missing?(name, *)
  n = method_to_field(name.id2name)
  self.class::ALLOWED_FIELDS.include?(n.chomp('=')) || super
end