Class: Cayuga::Object::NamedObject
- Defined in:
- lib/cayuga/object/named_object.rb
Overview
Named Object
Instance Attribute Summary collapse
-
#object_name ⇒ Object
(also: #name)
readonly
Returns the value of attribute object_name.
Attributes inherited from Object
Class Method Summary collapse
- .create(factory, configuration, name) ⇒ Object
- .primary(name) ⇒ Object
- .primary?(_name) ⇒ Boolean
- .valid_name?(_factory, name) ⇒ Boolean
Instance Method Summary collapse
Methods included from Tools::Loggable
Instance Attribute Details
#object_name ⇒ Object (readonly) Also known as: name
Returns the value of attribute object_name.
8 9 10 |
# File 'lib/cayuga/object/named_object.rb', line 8 def object_name @object_name end |
Class Method Details
.create(factory, configuration, name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cayuga/object/named_object.rb', line 23 def self.create(factory, configuration, name) if factory.registered?(self, name) raise "#{stringify}[#{name}] already registered" end if primary?(name) primary = name alternate = nil else primary = primary(name) alternate = name end verify_name_validity(factory, primary, alternate) instance = create_primary(factory, configuration, primary(name)) factory.register(instance, self, alternate) unless alternate.nil? instance end |
.primary(name) ⇒ Object
19 20 21 |
# File 'lib/cayuga/object/named_object.rb', line 19 def self.primary(name) name end |
.primary?(_name) ⇒ Boolean
15 16 17 |
# File 'lib/cayuga/object/named_object.rb', line 15 def self.primary?(_name) true end |
.valid_name?(_factory, name) ⇒ Boolean
11 12 13 |
# File 'lib/cayuga/object/named_object.rb', line 11 def self.valid_name?(_factory, name) name != nil end |
Instance Method Details
#inspect ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cayuga/object/named_object.rb', line 41 def inspect case object_name when Hash result = object_name.map { |key, value| "@#{key}=\"#{value}\"" } .join(' ') "#<#{self.class.name}:#{object_id} #{result}>" else "#<#{self.class.name}:#{object_id} @name=\"#{object_name}\">" end end |