Class: Cda::MetaInfo::Field
- Inherits:
-
Virtus::Attribute
- Object
- Virtus::Attribute
- Cda::MetaInfo::Field
- Defined in:
- lib/cda/meta_info.rb
Instance Method Summary collapse
- #allowed? ⇒ Boolean
- #build_method ⇒ Object
- #collection? ⇒ Boolean
- #complex? ⇒ Boolean
- #element_name ⇒ Object
- #fully_qualified_name ⇒ Object
- #get_value(instance) ⇒ Object
- #kind ⇒ Object
- #model_class ⇒ Object
- #new_instance ⇒ Object
- #prohibited? ⇒ Boolean
- #set_value(instance, value) ⇒ Object
- #wrapper_element_name ⇒ Object
Instance Method Details
#allowed? ⇒ Boolean
55 56 57 |
# File 'lib/cda/meta_info.rb', line 55 def allowed? !prohibited? end |
#build_method ⇒ Object
77 78 79 |
# File 'lib/cda/meta_info.rb', line 77 def build_method annotations[:build_method] end |
#collection? ⇒ Boolean
67 68 69 |
# File 'lib/cda/meta_info.rb', line 67 def collection? type.respond_to?(:member_type) end |
#complex? ⇒ Boolean
51 52 53 |
# File 'lib/cda/meta_info.rb', line 51 def complex? model_class.respond_to?(:attribute_set) end |
#element_name ⇒ Object
71 72 73 74 75 |
# File 'lib/cda/meta_info.rb', line 71 def element_name @element_name ||= begin sanitize_element_name(model_class.respond_to?(:template_type) ? model_class.template_type : name) end end |
#fully_qualified_name ⇒ Object
33 34 35 36 37 |
# File 'lib/cda/meta_info.rb', line 33 def fully_qualified_name sanitized_name = sanitize_element_name(name) ns = annotations[:ns] !ns.nil? ? "#{ns}:#{sanitized_name}" : sanitized_name end |
#get_value(instance) ⇒ Object
39 40 41 |
# File 'lib/cda/meta_info.rb', line 39 def get_value(instance) instance.send(name) end |
#kind ⇒ Object
63 64 65 |
# File 'lib/cda/meta_info.rb', line 63 def kind annotations.fetch(:kind, :element) end |
#model_class ⇒ Object
47 48 49 |
# File 'lib/cda/meta_info.rb', line 47 def model_class respond_to?(:member_type) ? member_type.primitive : type.primitive end |
#new_instance ⇒ Object
88 89 90 |
# File 'lib/cda/meta_info.rb', line 88 def new_instance type.primitive.new end |
#prohibited? ⇒ Boolean
59 60 61 |
# File 'lib/cda/meta_info.rb', line 59 def prohibited? annotations[:use] == :prohibited end |
#set_value(instance, value) ⇒ Object
43 44 45 |
# File 'lib/cda/meta_info.rb', line 43 def set_value(instance, value) instance.send("#{name}=", value) end |
#wrapper_element_name ⇒ Object
81 82 83 84 85 86 |
# File 'lib/cda/meta_info.rb', line 81 def wrapper_element_name @wrapper_element_name ||= begin name, _ = annotations[:wrap_with] sanitize_element_name(name) end end |