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.
91 92 93 94 95 96 97 98 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 91 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.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def base_id @base_id end |
#controllable_acl ⇒ Object
Returns the value of attribute controllable_acl.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def controllable_acl @controllable_acl end |
#controllable_policy ⇒ Object
Returns the value of attribute controllable_policy.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def controllable_policy @controllable_policy end |
#creatable ⇒ Object
Returns the value of attribute creatable.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def creatable @creatable end |
#description ⇒ Object
Returns the value of attribute description.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def description @description end |
#display_name ⇒ Object
Returns the value of attribute display_name.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def display_name @display_name end |
#fileable ⇒ Object
Returns the value of attribute fileable.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def fileable @fileable end |
#fulltext_indexed ⇒ Object
Returns the value of attribute fulltext_indexed.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def fulltext_indexed @fulltext_indexed end |
#id ⇒ Object
Returns the value of attribute id.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def id @id end |
#included_in_supertype_query ⇒ Object
Returns the value of attribute included_in_supertype_query.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def included_in_supertype_query @included_in_supertype_query end |
#local_name ⇒ Object
Returns the value of attribute local_name.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def local_name @local_name end |
#local_namespace ⇒ Object
Returns the value of attribute local_namespace.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def local_namespace @local_namespace end |
#parent_type ⇒ Object
Returns the value of attribute parent_type.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def parent_type @parent_type end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
88 89 90 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 88 def properties @properties end |
#property_definitions ⇒ Object
Returns the value of attribute property_definitions.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def property_definitions @property_definitions end |
#query_name ⇒ Object
Returns the value of attribute query_name.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def query_name @query_name end |
#queryable ⇒ Object
Returns the value of attribute queryable.
89 90 91 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 89 def queryable @queryable end |
Class Method Details
.adapter_class ⇒ Object
73 74 75 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 73 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 |
# 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||=[] @self_property_definitions<<pd 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
108 109 110 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 108 def ==(other) self.cmis_object_id == other.cmis_object_id end |
#adapter(context:) ⇒ Object
104 105 106 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 104 def adapter(context:) adapter_class.new(self, context: context) end |
#adapter_class ⇒ Object
100 101 102 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 100 def adapter_class self.class.adapter_class end |
#copy_properties_values_of(object) ⇒ Object
112 113 114 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 112 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
116 117 118 119 120 121 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 116 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
123 124 125 |
# File 'lib/cmis_server/base_objects/base_type.rb', line 123 def to_renderable_object CmisServer::RenderableObject.new(base_object: self) end |