Class: RailsConnector::Attribute

Inherits:
AbstractModel
  • Object
show all
Defined in:
app/models/rails_connector/attribute.rb

Overview

The methods date?, enum?, html?, linklist?, markdown?, multienum?, string? and text? are created by meta programming have no documentation of their own. Warning: Dependent on the setup of your DB replication, most tables with meta information will not be available on your live system!

Constant Summary collapse

TYPES =

The possible types of an attribute.

%w{date enum html linklist markdown multienum string text}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_name(*args) ⇒ Object

Convenience method for find_by_attribute_name



64
65
66
# File 'app/models/rails_connector/attribute.rb', line 64

def self.find_by_name(*args)
  self.find_by_attribute_name(*args)
end

.read_blob_data(name) ⇒ Object

Returns the blob as a JSON object.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/models/rails_connector/attribute.rb', line 69

def self.read_blob_data(name) #:nodoc:
  blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do            # these queries really pollute our logs!
    blob_name = if RailsConnector::BlobMapping.exists?
      RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonAttributeDict")
    else
      "#{name}.jsonAttributeDict"
    end

    RailsConnector::Blob.find_without_excluded_blob_data(blob_name)
  end

  return {} unless blob && blob.blob_data?

  JSON.parse(blob.blob_data)
end

Instance Method Details

#help_text(language = :de) ⇒ Object

The description of the attribute.



28
29
30
31
# File 'app/models/rails_connector/attribute.rb', line 28

def help_text(language = :de)
  load_blob_data
  @blob_data['helpTexts'].presence && @blob_data['helpTexts'][language.to_s]
end

#max_sizeObject



45
46
47
48
# File 'app/models/rails_connector/attribute.rb', line 45

def max_size
  load_blob_data
  @blob_data["maxSize"]
end

#min_sizeObject



50
51
52
53
# File 'app/models/rails_connector/attribute.rb', line 50

def min_size
  load_blob_data
  @blob_data["minSize"]
end

#searchable_in_cm?Boolean

Searchable in Content Manager.

Returns:

  • (Boolean)


34
35
36
37
# File 'app/models/rails_connector/attribute.rb', line 34

def searchable_in_cm?
  load_blob_data
  @blob_data['isSearchableInCM'].to_i != 0
end

#title(language = :de) ⇒ Object

The (human readable) title.



22
23
24
25
# File 'app/models/rails_connector/attribute.rb', line 22

def title(language = :de)
  load_blob_data
  @blob_data['titles'].presence && @blob_data['titles'][language.to_s]
end

#valuesObject

Returns the possible values if attribute is of type ‘enum’ or ‘multienum’.



40
41
42
43
# File 'app/models/rails_connector/attribute.rb', line 40

def values
  load_blob_data
  @blob_data['values']
end