Class: Ecoportal::API::V2::Page::Component::PeopleField
- Inherits:
-
Ecoportal::API::V2::Page::Component
- Object
- Common::BaseModel
- Common::Content::DoubleModel
- Ecoportal::API::V2::Page::Component
- Ecoportal::API::V2::Page::Component::PeopleField
- Defined in:
- lib/ecoportal/api/v2/page/component/people_field.rb
Constant Summary
Constants included from Common::Content::StringDigest
Common::Content::StringDigest::MAX_HASH_LABEL
Constants inherited from Common::Content::DoubleModel
Common::Content::DoubleModel::NOT_USED
Constants included from Common::Content::ClassHelpers
Common::Content::ClassHelpers::NOT_USED
Instance Attribute Summary
Attributes inherited from Common::Content::DoubleModel
Instance Method Summary collapse
-
#add(*ids) ⇒ Object
Attaches people.
-
#add_viewable(field_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED) ⇒ Object
Adds a field to the
viewable_fields. -
#configure(*conf) ⇒ Object
Quick config helper.
-
#delete(*ids) ⇒ Object
Deletes people.
-
#delete_viewable(field_id) ⇒ Object
Deletes a field from the
viewable_fields. - #to_s(delimiter: "\n") ⇒ Object
Methods inherited from Ecoportal::API::V2::Page::Component
#attached?, #bindings, #bindings?, #forces, get_class, #indexable_label, #multi_section?, new_doc, #ooze, #ref, #ref_backend, #section
Methods included from Common::Content::StringDigest
Methods inherited from Common::Content::DoubleModel
#_doc_key, #as_json, #as_update, #consolidate!, #dirty?, #doc, embeds_many, embeds_one, enforce!, #initialize, #key, #key=, key?, new_uuid, #original_doc, pass_reader, pass_writer, passarray, passboolean, passdate, passforced, passkey, passthrough, #print_pretty, #replace_doc, #reset!, #root, #to_json
Methods included from Common::Content::ClassHelpers
#inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant, #to_time, #used_param?
Constructor Details
This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel
Instance Method Details
#add(*ids) ⇒ Object
Attaches people
24 25 26 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 24 def add(*ids) people_ids << ids end |
#add_viewable(field_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED) ⇒ Object
Adds a field to the viewable_fields
34 35 36 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 34 def add_viewable(field_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED) viewable_fields.upsert!({"id" => field_id}, pos: pos, before: before, after: after) end |
#configure(*conf) ⇒ Object
Quick config helper
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 65 def configure(*conf) conf.each_with_object([]) do |cnf, unused| case cnf when :snapshot self.attach_mode = "snapshot" when :live self.attach_mode = "live" when :me_button self. = true when :singular self.singular = true when Hash supported = [:singular, :permits, :requires] unless (rest = hash_except(cnf.dup, *supported)).empty? unused.push(rest) end if cnf.key?(:singular) then self.singular = !!cnf[:singular] end if cnf.key?(:permits) if permits = cnf[:permits] self. = true configure_permits(*[permits].flatten.compact) else self. = false end end if cnf.key?(:requires) self.singular = false if requires = cnf[:requires] self.required = true self.requires_number = requires else self.required = false self.requires_number = nil end end else unused.push(cnf) end end.yield_self do |unused| super(*unused) end end |
#delete(*ids) ⇒ Object
Deletes people
29 30 31 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 29 def delete(*ids) people_ids.reject! {|id| ids.include?(id)} end |
#delete_viewable(field_id) ⇒ Object
Deletes a field from the viewable_fields
39 40 41 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 39 def delete_viewable(field_id) viewable_fields.delete!(field_id) end |
#to_s(delimiter: "\n") ⇒ Object
43 44 45 |
# File 'lib/ecoportal/api/v2/page/component/people_field.rb', line 43 def to_s(delimiter: "\n") people_ids.to_a.join(delimiter) end |