class Cda::MetaInfo
Attributes
attributes[R]
elements[R]
text[R]
Public Class Methods
for(klass)
click to toggle source
# File lib/cda/meta_info.rb, line 6 def self.for(klass) new(klass) end
new(klass)
click to toggle source
# File lib/cda/meta_info.rb, line 16 def initialize(klass) fields = convert_to_fields(klass.attribute_set) @elements, @attributes, @text = divide_fields_by_kind(fields) end
Public Instance Methods
has_text?()
click to toggle source
# File lib/cda/meta_info.rb, line 10 def has_text? !text.nil? end
Private Instance Methods
convert_to_fields(attribute_set)
click to toggle source
# File lib/cda/meta_info.rb, line 21 def convert_to_fields(attribute_set) attribute_set.map { |attr| Field.new(attr) } end
divide_fields_by_kind(fields)
click to toggle source
# File lib/cda/meta_info.rb, line 25 def divide_fields_by_kind(fields) #noinspection RubyArgCount allowed_fields = fields.select { |f| f.allowed? } groups = allowed_fields.group_by { |f| (f.name == :_text) ? :text : f.kind } [groups[:element] || [], groups[:attribute] || [], groups[:text] && groups[:text].first] end