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_attribute_name ⇒ Object
- #link_attribute_name=(val) ⇒ Object
- #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.
498 499 500 |
# File 'lib/etna/clients/magma/models.rb', line 498 def initialize(raw = {}) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
496 497 498 |
# File 'lib/etna/clients/magma/models.rb', line 496 def raw @raw end |
Class Method Details
.copy(source, dest, attributes: COPYABLE_ATTRIBUTE_ATTRIBUTES) ⇒ Object
657 658 659 660 661 662 663 |
# File 'lib/etna/clients/magma/models.rb', line 657 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
621 622 623 |
# File 'lib/etna/clients/magma/models.rb', line 621 def attribute_group raw['attribute_group'] end |
#attribute_group=(val) ⇒ Object
625 626 627 |
# File 'lib/etna/clients/magma/models.rb', line 625 def attribute_group=(val) raw['attribute_group'] = val end |
#attribute_name ⇒ Object
530 531 532 |
# File 'lib/etna/clients/magma/models.rb', line 530 def attribute_name @raw['attribute_name'] || "" end |
#attribute_name=(val) ⇒ Object
534 535 536 |
# File 'lib/etna/clients/magma/models.rb', line 534 def attribute_name=(val) @raw['attribute_name'] = val end |
#attribute_type ⇒ Object
538 539 540 |
# File 'lib/etna/clients/magma/models.rb', line 538 def attribute_type @raw['attribute_type'] && AttributeType.new(@raw['attribute_type']) end |
#attribute_type=(val) ⇒ Object
548 549 550 551 |
# File 'lib/etna/clients/magma/models.rb', line 548 def attribute_type=(val) val = val.to_s if val @raw['attribute_type'] = val end |
#description ⇒ Object
577 578 579 |
# File 'lib/etna/clients/magma/models.rb', line 577 def description raw['description'] end |
#description=(val) ⇒ Object
581 582 583 |
# File 'lib/etna/clients/magma/models.rb', line 581 def description=(val) @raw['description'] = val end |
#display_name ⇒ Object
585 586 587 |
# File 'lib/etna/clients/magma/models.rb', line 585 def display_name raw['display_name'] end |
#display_name=(val) ⇒ Object
589 590 591 |
# File 'lib/etna/clients/magma/models.rb', line 589 def display_name=(val) raw['display_name'] = val end |
#format_hint ⇒ Object
605 606 607 |
# File 'lib/etna/clients/magma/models.rb', line 605 def format_hint raw['format_hint'] end |
#format_hint=(val) ⇒ Object
609 610 611 |
# File 'lib/etna/clients/magma/models.rb', line 609 def format_hint=(val) raw['format_hint'] = val end |
#hidden ⇒ Object
629 630 631 |
# File 'lib/etna/clients/magma/models.rb', line 629 def hidden raw['hidden'] end |
#hidden=(val) ⇒ Object
633 634 635 |
# File 'lib/etna/clients/magma/models.rb', line 633 def hidden=(val) raw['hidden'] = val end |
#is_edited?(other) ⇒ Boolean
502 503 504 505 506 507 508 509 510 |
# File 'lib/etna/clients/magma/models.rb', line 502 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
542 543 544 545 546 |
# File 'lib/etna/clients/magma/models.rb', line 542 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_attribute_name ⇒ Object
553 554 555 |
# File 'lib/etna/clients/magma/models.rb', line 553 def link_attribute_name @raw['link_attribute_name'] end |
#link_attribute_name=(val) ⇒ Object
557 558 559 |
# File 'lib/etna/clients/magma/models.rb', line 557 def link_attribute_name=(val) @raw['link_attribute_name'] = val end |
#link_model_name ⇒ Object
561 562 563 |
# File 'lib/etna/clients/magma/models.rb', line 561 def link_model_name @raw['link_model_name'] end |
#link_model_name=(val) ⇒ Object
565 566 567 |
# File 'lib/etna/clients/magma/models.rb', line 565 def link_model_name=(val) @raw['link_model_name'] = val end |
#match ⇒ Object
593 594 595 |
# File 'lib/etna/clients/magma/models.rb', line 593 def match raw['match'] end |
#name ⇒ Object
522 523 524 |
# File 'lib/etna/clients/magma/models.rb', line 522 def name @raw['name'] || "" end |
#name=(val) ⇒ Object
526 527 528 |
# File 'lib/etna/clients/magma/models.rb', line 526 def name=(val) @raw['name'] = val end |
#options ⇒ Object
645 646 647 |
# File 'lib/etna/clients/magma/models.rb', line 645 def raw['options'] end |
#read_only ⇒ Object
613 614 615 |
# File 'lib/etna/clients/magma/models.rb', line 613 def read_only raw['read_only'] end |
#read_only=(val) ⇒ Object
617 618 619 |
# File 'lib/etna/clients/magma/models.rb', line 617 def read_only=(val) raw['read_only'] = val end |
#restricted ⇒ Object
597 598 599 |
# File 'lib/etna/clients/magma/models.rb', line 597 def restricted raw['restricted'] end |
#restricted=(val) ⇒ Object
601 602 603 |
# File 'lib/etna/clients/magma/models.rb', line 601 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.
513 514 515 516 517 518 519 520 |
# File 'lib/etna/clients/magma/models.rb', line 513 def set_field_defaults! @raw.replace({ 'hidden' => false, 'read_only' => false, 'restricted' => false, 'validation' => nil, }.merge(@raw)) end |
#unique ⇒ Object
569 570 571 |
# File 'lib/etna/clients/magma/models.rb', line 569 def unique raw['unique'] end |
#unique=(val) ⇒ Object
573 574 575 |
# File 'lib/etna/clients/magma/models.rb', line 573 def unique=(val) raw['unique'] = val end |
#validation ⇒ Object
637 638 639 |
# File 'lib/etna/clients/magma/models.rb', line 637 def validation raw['validation'] end |
#validation=(val) ⇒ Object
641 642 643 |
# File 'lib/etna/clients/magma/models.rb', line 641 def validation=(val) raw['validation'] = val end |