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 =
NOTE! The Attribute class returns description as desc, where as actions take it in as description. There are shortcut methods that try to handle this on the action class side of things. Ideally we would make this more consistent in the near future.
[ :attribute_name, :attribute_type, :desc, :display_name, :format_hint, :hidden, :link_model_name, :read_only, :attribute_group, :unique, :validation, :restricted ]
- 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
- #desc ⇒ Object
- #desc=(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_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.
453 454 455 |
# File 'lib/etna/clients/magma/models.rb', line 453 def initialize(raw = {}) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
451 452 453 |
# File 'lib/etna/clients/magma/models.rb', line 451 def raw @raw end |
Class Method Details
.copy(source, dest, attributes: COPYABLE_ATTRIBUTE_ATTRIBUTES) ⇒ Object
597 598 599 600 601 602 603 |
# File 'lib/etna/clients/magma/models.rb', line 597 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
558 559 560 |
# File 'lib/etna/clients/magma/models.rb', line 558 def attribute_group raw['attribute_group'] end |
#attribute_group=(val) ⇒ Object
562 563 564 |
# File 'lib/etna/clients/magma/models.rb', line 562 def attribute_group=(val) raw['attribute_group'] = val end |
#attribute_name ⇒ Object
475 476 477 |
# File 'lib/etna/clients/magma/models.rb', line 475 def attribute_name @raw['attribute_name'] || "" end |
#attribute_name=(val) ⇒ Object
479 480 481 |
# File 'lib/etna/clients/magma/models.rb', line 479 def attribute_name=(val) @raw['attribute_name'] = val end |
#attribute_type ⇒ Object
483 484 485 |
# File 'lib/etna/clients/magma/models.rb', line 483 def attribute_type @raw['attribute_type'] && AttributeType.new(@raw['attribute_type']) end |
#attribute_type=(val) ⇒ Object
493 494 495 496 |
# File 'lib/etna/clients/magma/models.rb', line 493 def attribute_type=(val) val = val.to_s if val @raw['attribute_type'] = val end |
#desc ⇒ Object
514 515 516 |
# File 'lib/etna/clients/magma/models.rb', line 514 def desc raw['desc'] end |
#desc=(val) ⇒ Object
518 519 520 |
# File 'lib/etna/clients/magma/models.rb', line 518 def desc=(val) @raw['desc'] = val end |
#display_name ⇒ Object
522 523 524 |
# File 'lib/etna/clients/magma/models.rb', line 522 def display_name raw['display_name'] end |
#display_name=(val) ⇒ Object
526 527 528 |
# File 'lib/etna/clients/magma/models.rb', line 526 def display_name=(val) raw['display_name'] = val end |
#format_hint ⇒ Object
542 543 544 |
# File 'lib/etna/clients/magma/models.rb', line 542 def format_hint raw['format_hint'] end |
#format_hint=(val) ⇒ Object
546 547 548 |
# File 'lib/etna/clients/magma/models.rb', line 546 def format_hint=(val) raw['format_hint'] = val end |
#hidden ⇒ Object
566 567 568 |
# File 'lib/etna/clients/magma/models.rb', line 566 def hidden raw['hidden'] end |
#hidden=(val) ⇒ Object
570 571 572 |
# File 'lib/etna/clients/magma/models.rb', line 570 def hidden=(val) raw['hidden'] = val end |
#is_project_name_reference?(model_name) ⇒ Boolean
487 488 489 490 491 |
# File 'lib/etna/clients/magma/models.rb', line 487 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
498 499 500 |
# File 'lib/etna/clients/magma/models.rb', line 498 def link_model_name @raw['link_model_name'] end |
#link_model_name=(val) ⇒ Object
502 503 504 |
# File 'lib/etna/clients/magma/models.rb', line 502 def link_model_name=(val) @raw['link_model_name'] = val end |
#match ⇒ Object
530 531 532 |
# File 'lib/etna/clients/magma/models.rb', line 530 def match raw['match'] end |
#name ⇒ Object
467 468 469 |
# File 'lib/etna/clients/magma/models.rb', line 467 def name @raw['name'] || "" end |
#name=(val) ⇒ Object
471 472 473 |
# File 'lib/etna/clients/magma/models.rb', line 471 def name=(val) @raw['name'] = val end |
#options ⇒ Object
582 583 584 |
# File 'lib/etna/clients/magma/models.rb', line 582 def raw['options'] end |
#read_only ⇒ Object
550 551 552 |
# File 'lib/etna/clients/magma/models.rb', line 550 def read_only raw['read_only'] end |
#read_only=(val) ⇒ Object
554 555 556 |
# File 'lib/etna/clients/magma/models.rb', line 554 def read_only=(val) raw['read_only'] = val end |
#restricted ⇒ Object
534 535 536 |
# File 'lib/etna/clients/magma/models.rb', line 534 def restricted raw['restricted'] end |
#restricted=(val) ⇒ Object
538 539 540 |
# File 'lib/etna/clients/magma/models.rb', line 538 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.
458 459 460 461 462 463 464 465 |
# File 'lib/etna/clients/magma/models.rb', line 458 def set_field_defaults! @raw.replace({ 'hidden' => false, 'read_only' => false, 'restricted' => false, 'validation' => nil, }.merge(@raw)) end |
#unique ⇒ Object
506 507 508 |
# File 'lib/etna/clients/magma/models.rb', line 506 def unique raw['unique'] end |
#unique=(val) ⇒ Object
510 511 512 |
# File 'lib/etna/clients/magma/models.rb', line 510 def unique=(val) raw['unique'] = val end |
#validation ⇒ Object
574 575 576 |
# File 'lib/etna/clients/magma/models.rb', line 574 def validation raw['validation'] end |
#validation=(val) ⇒ Object
578 579 580 |
# File 'lib/etna/clients/magma/models.rb', line 578 def validation=(val) raw['validation'] = val end |