Class: CmisServer::BaseType
- Inherits:
-
Object
- Object
- CmisServer::BaseType
- Defined in:
- lib/cmis_server/base_objects/base_type.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.base_id ⇒ Object
readonly
Should be overwrited by base types.
-
.controllable_acl ⇒ Object
readonly
Returns the value of attribute controllable_acl.
-
.controllable_policy ⇒ Object
readonly
Returns the value of attribute controllable_policy.
-
.creatable ⇒ Object
readonly
Returns the value of attribute creatable.
-
.description ⇒ Object
readonly
Returns the value of attribute description.
-
.display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
.fileable ⇒ Object
readonly
Returns the value of attribute fileable.
-
.fulltext_indexed ⇒ Object
readonly
Returns the value of attribute fulltext_indexed.
-
.id ⇒ Object
readonly
Returns the value of attribute id.
-
.included_in_supertype_query ⇒ Object
readonly
Returns the value of attribute included_in_supertype_query.
-
.local_name ⇒ Object
readonly
Returns the value of attribute local_name.
-
.local_namespace ⇒ Object
readonly
Returns the value of attribute local_namespace.
-
.parent_type ⇒ Object
readonly
Returns the value of attribute parent_type.
-
.query_name ⇒ Object
readonly
Returns the value of attribute query_name.
-
.queryable ⇒ Object
readonly
Returns the value of attribute queryable.
-
.self_property_definitions ⇒ Object
readonly
Returns the value of attribute self_property_definitions.
Instance Attribute Summary collapse
-
#base_id ⇒ Object
Returns the value of attribute base_id.
-
#controllable_acl ⇒ Object
Returns the value of attribute controllable_acl.
-
#controllable_policy ⇒ Object
Returns the value of attribute controllable_policy.
-
#creatable ⇒ Object
Returns the value of attribute creatable.
-
#description ⇒ Object
Returns the value of attribute description.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#fileable ⇒ Object
Returns the value of attribute fileable.
-
#fulltext_indexed ⇒ Object
Returns the value of attribute fulltext_indexed.
-
#id ⇒ Object
Returns the value of attribute id.
-
#included_in_supertype_query ⇒ Object
Returns the value of attribute included_in_supertype_query.
-
#local_name ⇒ Object
Returns the value of attribute local_name.
-
#local_namespace ⇒ Object
Returns the value of attribute local_namespace.
-
#parent_type ⇒ Object
Returns the value of attribute parent_type.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#property_definitions ⇒ Object
Returns the value of attribute property_definitions.
-
#query_name ⇒ Object
Returns the value of attribute query_name.
-
#queryable ⇒ Object
Returns the value of attribute queryable.
Class Method Summary collapse
- .adapter_class ⇒ Object
- .base_type ⇒ Object
- .parent_id ⇒ Object
- .parent_property_definitions ⇒ Object
- .property(id, opts) ⇒ Object
- .property_definitions ⇒ Object
- .type_definition(opts = {}) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #adapter(context:) ⇒ Object
- #adapter_class ⇒ Object
- #copy_properties_values_of(object) ⇒ Object
-
#initialize(attrs = {}) ⇒ BaseType
constructor
A new instance of BaseType.
- #initialize_properties ⇒ Object
- #to_renderable_object ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ BaseType
Returns a new instance of BaseType.
104 105 106 107 108 109 110 111 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 104 def initialize(attrs={}) initialize_properties attrs.to_h.each do |property,value| self.send(property.to_s.gsub(/[^0-9a-z]/i, '_').underscore+"=",value) end end |
Class Attribute Details
.base_id ⇒ Object (readonly)
Should be overwrited by base types
54 55 56 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 54 def base_id @base_id end |
.controllable_acl ⇒ Object (readonly)
Returns the value of attribute controllable_acl.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def controllable_acl @controllable_acl end |
.controllable_policy ⇒ Object (readonly)
Returns the value of attribute controllable_policy.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def controllable_policy @controllable_policy end |
.creatable ⇒ Object (readonly)
Returns the value of attribute creatable.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def creatable @creatable end |
.description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def description @description end |
.display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def display_name @display_name end |
.fileable ⇒ Object (readonly)
Returns the value of attribute fileable.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def fileable @fileable end |
.fulltext_indexed ⇒ Object (readonly)
Returns the value of attribute fulltext_indexed.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def fulltext_indexed @fulltext_indexed end |
.id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def id @id end |
.included_in_supertype_query ⇒ Object (readonly)
Returns the value of attribute included_in_supertype_query.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def included_in_supertype_query @included_in_supertype_query end |
.local_name ⇒ Object (readonly)
Returns the value of attribute local_name.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def local_name @local_name end |
.local_namespace ⇒ Object (readonly)
Returns the value of attribute local_namespace.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def local_namespace @local_namespace end |
.parent_type ⇒ Object (readonly)
Returns the value of attribute parent_type.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def parent_type @parent_type end |
.query_name ⇒ Object (readonly)
Returns the value of attribute query_name.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def query_name @query_name end |
.queryable ⇒ Object (readonly)
Returns the value of attribute queryable.
5 6 7 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 5 def queryable @queryable end |
.self_property_definitions ⇒ Object (readonly)
Returns the value of attribute self_property_definitions.
21 22 23 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 21 def self_property_definitions @self_property_definitions end |
Instance Attribute Details
#base_id ⇒ Object
Returns the value of attribute base_id.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def base_id @base_id end |
#controllable_acl ⇒ Object
Returns the value of attribute controllable_acl.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def controllable_acl @controllable_acl end |
#controllable_policy ⇒ Object
Returns the value of attribute controllable_policy.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def controllable_policy @controllable_policy end |
#creatable ⇒ Object
Returns the value of attribute creatable.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def creatable @creatable end |
#description ⇒ Object
Returns the value of attribute description.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def description @description end |
#display_name ⇒ Object
Returns the value of attribute display_name.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def display_name @display_name end |
#fileable ⇒ Object
Returns the value of attribute fileable.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def fileable @fileable end |
#fulltext_indexed ⇒ Object
Returns the value of attribute fulltext_indexed.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def fulltext_indexed @fulltext_indexed end |
#id ⇒ Object
Returns the value of attribute id.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def id @id end |
#included_in_supertype_query ⇒ Object
Returns the value of attribute included_in_supertype_query.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def included_in_supertype_query @included_in_supertype_query end |
#local_name ⇒ Object
Returns the value of attribute local_name.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def local_name @local_name end |
#local_namespace ⇒ Object
Returns the value of attribute local_namespace.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def local_namespace @local_namespace end |
#parent_type ⇒ Object
Returns the value of attribute parent_type.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def parent_type @parent_type end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
101 102 103 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 101 def properties @properties end |
#property_definitions ⇒ Object
Returns the value of attribute property_definitions.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def property_definitions @property_definitions end |
#query_name ⇒ Object
Returns the value of attribute query_name.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def query_name @query_name end |
#queryable ⇒ Object
Returns the value of attribute queryable.
102 103 104 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 102 def queryable @queryable end |
Class Method Details
.adapter_class ⇒ Object
86 87 88 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 86 def adapter_class "#{self.to_s}Adapter".constantize end |
.base_type ⇒ Object
45 46 47 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 45 def base_type self.parent_type ? self.parent_type.base_type : self end |
.parent_id ⇒ Object
49 50 51 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 49 def parent_id self.parent_type&.id end |
.parent_property_definitions ⇒ Object
62 63 64 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 62 def parent_property_definitions self.parent_type&.property_definitions.to_a end |
.property(id, opts) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 66 def property(id,opts) pd=CmisServer::PropertyDefinition.register_property_definition({id:id.freeze}.merge(opts)) @self_property_definitions||=[] # Gérer les tableaux figés - Créer une copie mutable si nécessaire if @self_property_definitions.frozen? @self_property_definitions = @self_property_definitions.dup end # Vérifier à nouveau après copie (au cas où le dup serait aussi figé) unless @self_property_definitions.frozen? @self_property_definitions<<pd else # Fallback : créer un nouveau tableau complètement @self_property_definitions = (@self_property_definitions.to_a + [pd]) end define_properties_methods(pd) end |
.property_definitions ⇒ Object
58 59 60 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 58 def property_definitions @self_property_definitions.to_a+parent_property_definitions end |
.type_definition(opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 23 def type_definition(opts={}) @id = CmisServer::Id.new(opts.fetch(:id).to_s) CmisServer::TypeRegistry.register_type(self.id, self) @parent_type = opts.fetch(:parent_type) @local_name = opts.fetch(:local_name,id) @local_namespace = opts.fetch(:local_namespace,'local') @query_name = opts.fetch(:query_name,id) @display_name = opts.fetch(:display_name,id) @description = opts.fetch(:description,'No description provided') @creatable = opts.fetch(:creatable ,false) @fileable = opts.fetch(:fileable ,false) @queryable = opts.fetch(:queryable ,false) @controllable_policy = opts.fetch(:controllable_policy ,false) @controllable_acl = opts.fetch(:controllable_acl ,false) @fulltext_indexed = opts.fetch(:fulltext_indexed ,false) @included_in_supertype_query = opts.fetch(:included_in_supertype_query,false) define_properties_methods(parent_property_definitions) end |
Instance Method Details
#==(other) ⇒ Object
121 122 123 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 121 def ==(other) self.cmis_object_id == other.cmis_object_id end |
#adapter(context:) ⇒ Object
117 118 119 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 117 def adapter(context:) adapter_class.new(self, context: context) end |
#adapter_class ⇒ Object
113 114 115 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 113 def adapter_class self.class.adapter_class end |
#copy_properties_values_of(object) ⇒ Object
125 126 127 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 125 def copy_properties_values_of object self.properties.each{|_k,property| property.value=object.send(property.property_definition.getter_method_name)} end |
#initialize_properties ⇒ Object
129 130 131 132 133 134 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 129 def initialize_properties all_prop_defs = (self.class.property_definitions.to_a + (@property_definitions.to_a || [])) @properties = all_prop_defs.map do |pd| [pd.id, Property.new(pd, pd.value, self)] end.to_h end |
#to_renderable_object ⇒ Object
136 137 138 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 136 def to_renderable_object CmisServer::RenderableObject.new(base_object: self) end |