Class: DbAgile::Core::Schema::Logical::Attribute
- Inherits:
-
Part
- Object
- SchemaObject
- Part
- DbAgile::Core::Schema::Logical::Attribute
- Defined in:
- lib/dbagile/core/schema/logical/attribute.rb
Instance Attribute Summary
Attributes inherited from Part
Attributes inherited from SchemaObject
Instance Method Summary collapse
- #_semantics_check(clazz, buffer) ⇒ Object
-
#default_value ⇒ Object
Returns default value.
- #dependencies(include_parent = false) ⇒ Object
-
#domain ⇒ Object
Returns attribute domain.
-
#mandatory? ⇒ Boolean
Returns default value.
- #relvar ⇒ Object
-
#to_s ⇒ Object
Returns a string representation.
-
#to_yaml(opts = {}) ⇒ Object
Delegation pattern on YAML flushing.
Methods inherited from Part
#_sanity_check, #dup, #initialize, #look_same_as?, #visit
Methods inherited from SchemaObject
#ancestors, #attribute?, #builder_args, #builder_handler, #candidate_key?, #composite?, #constraint?, #foreign_key?, #index?, #logical?, #outside_dependencies, #outside_dependents, #part?, #physical?, #primary_key?, #relation_variable, #relvar?, #relview?, #schema
Constructor Details
This class inherits a constructor from DbAgile::Core::Schema::Part
Instance Method Details
#_semantics_check(clazz, buffer) ⇒ Object
44 45 46 47 48 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 44 def _semantics_check(clazz, buffer) unless default_value.nil? or (domain === default_value) buffer.add_error(self, clazz::InvalidDefaultValue) end end |
#default_value ⇒ Object
Returns default value
17 18 19 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 17 def default_value definition[:default] end |
#dependencies(include_parent = false) ⇒ Object
35 36 37 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 35 def dependencies(include_parent = false) include_parent ? [ parent ] : [] end |
#domain ⇒ Object
Returns attribute domain
12 13 14 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 12 def domain definition[:domain] end |
#mandatory? ⇒ Boolean
Returns default value
22 23 24 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 22 def mandatory? !(definition[:mandatory] == false) end |
#relvar ⇒ Object
26 27 28 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 26 def relvar parent.parent end |
#to_s ⇒ Object
Returns a string representation
69 70 71 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 69 def to_s "Attribute #{relvar.name}::#{name} #{definition.inspect}" end |
#to_yaml(opts = {}) ⇒ Object
Delegation pattern on YAML flushing
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dbagile/core/schema/logical/attribute.rb', line 55 def to_yaml(opts = {}) YAML::quick_emit(self, opts){|out| defn = definition out.map("tag:yaml.org,2002:map", :inline ) do |map| map.add('domain', defn[:domain].to_s) map.add('mandatory', false) unless defn[:mandatory] unless defn[:default].nil? map.add('default', defn[:default]) end end } end |