Module: RailsConnector::Meta

Defined in:
lib/meta.rb,
lib/meta/version.rb,
app/models/rails_connector/meta/eager_loader.rb

Defined Under Namespace

Modules: ClassMethods Classes: EagerLoader

Constant Summary collapse

VERSION =
"1.8.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hello_im_rails_and_im_retarted_so_please_be_patient(&block) ⇒ Object

This method is an equivalent of Rails.logger.silence, which has been deprecated



7
8
9
10
11
12
13
14
# File 'lib/meta.rb', line 7

def self.hello_im_rails_and_im_retarted_so_please_be_patient(&block)
  begin
    old_logger_level, Rails.logger.level = Rails.logger.level, Logger::ERROR
    yield self
  ensure
    Rails.logger.level = old_logger_level
  end
end

.included(base) ⇒ Object

:nodoc:



16
17
18
19
# File 'lib/meta.rb', line 16

def self.included(base) #:nodoc:
  #  Class enhancements
  base.extend(ClassMethods)
end

Instance Method Details

#custom_attribute?(attr) ⇒ Boolean

Returns true, if the file format has an attribute of the given name.

Returns:

  • (Boolean)


41
42
43
# File 'lib/meta.rb', line 41

def custom_attribute?(attr)
  self.obj_class_definition.custom_attribute?(attr)
end

#custom_attributesObject

Returns the custom attributes in the form of a Hash.



36
37
38
# File 'lib/meta.rb', line 36

def custom_attributes
  self.obj_class_definition.custom_attributes
end

#editorObject

Return the current editor as a String. If there is no edited content, which is always the case in live mode, an empty String is returned. The ‘contents’ table is queried for this information.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/meta.rb', line 89

def editor
  return @editor if @editor

  load_meta_details

  content_id = if self.edited?
    .edited_content_id
  else
    .released_cont_id
  end

  if content_id
    content = RailsConnector::Content.find(content_id)
    @editor = content.editor
  else
    @editor = ''
  end
end

#has_custom_ruby_class?Boolean

Returns true, if there is a custom Ruby class defined for the object or false, if it is represented by RailsConnector::Obj

Returns:

  • (Boolean)


31
32
33
# File 'lib/meta.rb', line 31

def has_custom_ruby_class?
  self.class.is_custom_ruby_class?
end

#mandatory_attribute?(attr) ⇒ Boolean

Returns true, if the file format has an mandatory attribute of the given name.

Returns:

  • (Boolean)


56
57
58
# File 'lib/meta.rb', line 56

def mandatory_attribute?(attr)
  self.obj_class_definition.mandatory_attribute?(attr)
end

#mandatory_attribute_names(options = {}) ⇒ Object

Returns an Array of String of all mandatory attributes, no mather if it’s custom or built-in. Built-in attributes are underscored (valid_from, not validFrom). Possible options are:

:only_custom_attributes

Return only custom attributes, omit

built-in attributes like content_type or valid_from.



51
52
53
# File 'lib/meta.rb', line 51

def mandatory_attribute_names(options = {})
  self.obj_class_definition.mandatory_attribute_names(options)
end

#obj_class_definitionObject Also known as: obj_class_def

The RailsConnector::ObjClass object for this file format. This will always return a proper object, even if no custom Ruby class exists.



24
25
26
# File 'lib/meta.rb', line 24

def obj_class_definition
  @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(self.obj_class)
end

#reminder_commentObject

Returns the reminder comment, if a reminder is set.



75
76
77
78
# File 'lib/meta.rb', line 75

def reminder_comment
  load_meta_details
  .reminder_comment
end

#reminder_fromObject

Returns the time of the reminder, if it is set.



68
69
70
71
72
# File 'lib/meta.rb', line 68

def reminder_from
  load_meta_details
  .reminder_from.presence &&
      ::RailsConnector::DateAttribute.parse(.reminder_from)
end

#versionObject

Returns the version of this object. This number is increased every time this object is released.



62
63
64
65
# File 'lib/meta.rb', line 62

def version
  load_meta_details
  .version.presence.to_i || 0
end

#workflow_nameObject

Return the name of the workflow, that is assigned to this object.



81
82
83
84
# File 'lib/meta.rb', line 81

def workflow_name
  load_meta_details
  .workflow_name
end