Class: Etna::Clients::Magma::Attribute
- Inherits:
-
Object
- Object
- Etna::Clients::Magma::Attribute
- Defined in:
- lib/etna/clients/magma/models.rb
Constant Summary collapse
- COPYABLE_ATTRIBUTE_ATTRIBUTES =
[ :attribute_name, :attribute_type, :display_name, :format_hint, :hidden, :link_model_name, :read_only, :attribute_group, :unique, :validation, :restricted, :description ]
- EDITABLE_ATTRIBUTE_ATTRIBUTES =
UpdateAttributeAction.members & COPYABLE_ATTRIBUTE_ATTRIBUTES
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #attribute_group ⇒ Object
- #attribute_group=(val) ⇒ Object
- #attribute_name ⇒ Object
- #attribute_name=(val) ⇒ Object
- #attribute_type ⇒ Object
- #attribute_type=(val) ⇒ Object
- #description ⇒ Object
- #description=(val) ⇒ Object
- #display_name ⇒ Object
- #display_name=(val) ⇒ Object
- #format_hint ⇒ Object
- #format_hint=(val) ⇒ Object
- #hidden ⇒ Object
- #hidden=(val) ⇒ Object
-
#initialize(raw = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #is_edited?(other) ⇒ Boolean
- #is_project_name_reference?(model_name) ⇒ Boolean
- #link_model_name ⇒ Object
- #link_model_name=(val) ⇒ Object
- #match ⇒ Object
- #name ⇒ Object
- #name=(val) ⇒ Object
- #options ⇒ Object
- #read_only ⇒ Object
- #read_only=(val) ⇒ Object
- #restricted ⇒ Object
- #restricted=(val) ⇒ Object
-
#set_field_defaults! ⇒ Object
Sets certain attribute fields which are implicit, even when not set, to match server behavior.
- #unique ⇒ Object
- #unique=(val) ⇒ Object
- #validation ⇒ Object
- #validation=(val) ⇒ Object
Constructor Details
#initialize(raw = {}) ⇒ Attribute
Returns a new instance of Attribute.
445 446 447 |
# File 'lib/etna/clients/magma/models.rb', line 445 def initialize(raw = {}) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
443 444 445 |
# File 'lib/etna/clients/magma/models.rb', line 443 def raw @raw end |
Class Method Details
.copy(source, dest, attributes: COPYABLE_ATTRIBUTE_ATTRIBUTES) ⇒ Object
596 597 598 599 600 601 602 |
# File 'lib/etna/clients/magma/models.rb', line 596 def self.copy(source, dest, attributes: COPYABLE_ATTRIBUTE_ATTRIBUTES) attributes.each do |attr_name| next unless dest.respond_to?(:"#{attr_name}=") source_v = source.send(attr_name) dest.send(:"#{attr_name}=", source_v) end end |
Instance Method Details
#attribute_group ⇒ Object
560 561 562 |
# File 'lib/etna/clients/magma/models.rb', line 560 def attribute_group raw['attribute_group'] end |
#attribute_group=(val) ⇒ Object
564 565 566 |
# File 'lib/etna/clients/magma/models.rb', line 564 def attribute_group=(val) raw['attribute_group'] = val end |
#attribute_name ⇒ Object
477 478 479 |
# File 'lib/etna/clients/magma/models.rb', line 477 def attribute_name @raw['attribute_name'] || "" end |
#attribute_name=(val) ⇒ Object
481 482 483 |
# File 'lib/etna/clients/magma/models.rb', line 481 def attribute_name=(val) @raw['attribute_name'] = val end |
#attribute_type ⇒ Object
485 486 487 |
# File 'lib/etna/clients/magma/models.rb', line 485 def attribute_type @raw['attribute_type'] && AttributeType.new(@raw['attribute_type']) end |
#attribute_type=(val) ⇒ Object
495 496 497 498 |
# File 'lib/etna/clients/magma/models.rb', line 495 def attribute_type=(val) val = val.to_s if val @raw['attribute_type'] = val end |
#description ⇒ Object
516 517 518 |
# File 'lib/etna/clients/magma/models.rb', line 516 def description raw['description'] end |
#description=(val) ⇒ Object
520 521 522 |
# File 'lib/etna/clients/magma/models.rb', line 520 def description=(val) @raw['description'] = val end |
#display_name ⇒ Object
524 525 526 |
# File 'lib/etna/clients/magma/models.rb', line 524 def display_name raw['display_name'] end |
#display_name=(val) ⇒ Object
528 529 530 |
# File 'lib/etna/clients/magma/models.rb', line 528 def display_name=(val) raw['display_name'] = val end |
#format_hint ⇒ Object
544 545 546 |
# File 'lib/etna/clients/magma/models.rb', line 544 def format_hint raw['format_hint'] end |
#format_hint=(val) ⇒ Object
548 549 550 |
# File 'lib/etna/clients/magma/models.rb', line 548 def format_hint=(val) raw['format_hint'] = val end |
#hidden ⇒ Object
568 569 570 |
# File 'lib/etna/clients/magma/models.rb', line 568 def hidden raw['hidden'] end |
#hidden=(val) ⇒ Object
572 573 574 |
# File 'lib/etna/clients/magma/models.rb', line 572 def hidden=(val) raw['hidden'] = val end |
#is_edited?(other) ⇒ Boolean
449 450 451 452 453 454 455 456 457 |
# File 'lib/etna/clients/magma/models.rb', line 449 def is_edited?(other) # Don't just override == in case need to do a full comparison. editable_attribute_names = Attribute::EDITABLE_ATTRIBUTE_ATTRIBUTES.map(&:to_s) self_editable = raw.slice(*editable_attribute_names) other_editable = other.raw.slice(*editable_attribute_names) self_editable != other_editable end |
#is_project_name_reference?(model_name) ⇒ Boolean
489 490 491 492 493 |
# File 'lib/etna/clients/magma/models.rb', line 489 def is_project_name_reference?(model_name) return true if model_name == 'project' && attribute_type == AttributeType::IDENTIFIER return true if link_model_name == 'project' false end |
#link_model_name ⇒ Object
500 501 502 |
# File 'lib/etna/clients/magma/models.rb', line 500 def link_model_name @raw['link_model_name'] end |
#link_model_name=(val) ⇒ Object
504 505 506 |
# File 'lib/etna/clients/magma/models.rb', line 504 def link_model_name=(val) @raw['link_model_name'] = val end |
#match ⇒ Object
532 533 534 |
# File 'lib/etna/clients/magma/models.rb', line 532 def match raw['match'] end |
#name ⇒ Object
469 470 471 |
# File 'lib/etna/clients/magma/models.rb', line 469 def name @raw['name'] || "" end |
#name=(val) ⇒ Object
473 474 475 |
# File 'lib/etna/clients/magma/models.rb', line 473 def name=(val) @raw['name'] = val end |
#options ⇒ Object
584 585 586 |
# File 'lib/etna/clients/magma/models.rb', line 584 def raw['options'] end |
#read_only ⇒ Object
552 553 554 |
# File 'lib/etna/clients/magma/models.rb', line 552 def read_only raw['read_only'] end |
#read_only=(val) ⇒ Object
556 557 558 |
# File 'lib/etna/clients/magma/models.rb', line 556 def read_only=(val) raw['read_only'] = val end |
#restricted ⇒ Object
536 537 538 |
# File 'lib/etna/clients/magma/models.rb', line 536 def restricted raw['restricted'] end |
#restricted=(val) ⇒ Object
540 541 542 |
# File 'lib/etna/clients/magma/models.rb', line 540 def restricted=(val) raw['restricted'] = val end |
#set_field_defaults! ⇒ Object
Sets certain attribute fields which are implicit, even when not set, to match server behavior.
460 461 462 463 464 465 466 467 |
# File 'lib/etna/clients/magma/models.rb', line 460 def set_field_defaults! @raw.replace({ 'hidden' => false, 'read_only' => false, 'restricted' => false, 'validation' => nil, }.merge(@raw)) end |
#unique ⇒ Object
508 509 510 |
# File 'lib/etna/clients/magma/models.rb', line 508 def unique raw['unique'] end |
#unique=(val) ⇒ Object
512 513 514 |
# File 'lib/etna/clients/magma/models.rb', line 512 def unique=(val) raw['unique'] = val end |
#validation ⇒ Object
576 577 578 |
# File 'lib/etna/clients/magma/models.rb', line 576 def validation raw['validation'] end |
#validation=(val) ⇒ Object
580 581 582 |
# File 'lib/etna/clients/magma/models.rb', line 580 def validation=(val) raw['validation'] = val end |