Class: EntitySchema::Fields::Abstract
- Inherits:
-
Object
- Object
- EntitySchema::Fields::Abstract
- Defined in:
- lib/entity_schema/fields/abstract.rb
Overview
Specification for fiend behaviour: internal and external
will be used for build Field object and for setup Field object
Defined Under Namespace
Classes: Specification
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#specification ⇒ Object
readonly
Returns the value of attribute specification.
-
#src_key ⇒ Object
readonly
Returns the value of attribute src_key.
Instance Method Summary collapse
-
#get(_obj) ⇒ Object
:nocov:.
- #given?(obj) ⇒ Boolean
-
#initialize(options) ⇒ Abstract
constructor
A new instance of Abstract.
- #public_get(obj) ⇒ Object
- #public_set(obj, value) ⇒ Object
-
#serialize(obj, output) ⇒ Object
:nocov:.
- #set(obj, value) ⇒ Object
Constructor Details
#initialize(options) ⇒ Abstract
Returns a new instance of Abstract.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/entity_schema/fields/abstract.rb', line 12 def initialize() @name ||= [:name] @owner_name = [:owner_name] @src_key ||= [:src_key] @ivar_name = :"@#{name}" @specification = Specification.new @specification.public_getter = [:public_getter] @specification.public_setter = [:public_setter] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/entity_schema/fields/abstract.rb', line 10 def name @name end |
#specification ⇒ Object (readonly)
Returns the value of attribute specification.
10 11 12 |
# File 'lib/entity_schema/fields/abstract.rb', line 10 def specification @specification end |
#src_key ⇒ Object (readonly)
Returns the value of attribute src_key.
10 11 12 |
# File 'lib/entity_schema/fields/abstract.rb', line 10 def src_key @src_key end |
Instance Method Details
#get(_obj) ⇒ Object
:nocov:
42 43 44 |
# File 'lib/entity_schema/fields/abstract.rb', line 42 def get(_obj) raise NotImplementedError end |
#given?(obj) ⇒ Boolean
33 34 35 |
# File 'lib/entity_schema/fields/abstract.rb', line 33 def given?(obj) obj.instance_variable_defined?(ivar_name) end |
#public_get(obj) ⇒ Object
28 29 30 31 |
# File 'lib/entity_schema/fields/abstract.rb', line 28 def public_get(obj) raise_public('Getter') unless specification.public_getter get(obj) end |
#public_set(obj, value) ⇒ Object
23 24 25 26 |
# File 'lib/entity_schema/fields/abstract.rb', line 23 def public_set(obj, value) raise_public('Setter') unless specification.public_setter set(obj, value) end |
#serialize(obj, output) ⇒ Object
:nocov:
47 48 49 |
# File 'lib/entity_schema/fields/abstract.rb', line 47 def serialize(obj, output) output[src_key] = read(obj) if given?(obj) end |
#set(obj, value) ⇒ Object
37 38 39 |
# File 'lib/entity_schema/fields/abstract.rb', line 37 def set(obj, value) write(obj, value) end |