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.
- #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
405 406 407 |
# File 'lib/etna/clients/magma/models.rb', line 405 def initialize(raw = {}) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
403 404 405 |
# File 'lib/etna/clients/magma/models.rb', line 403 def raw @raw end |
Class Method Details
.copy(source, dest, attributes: COPYABLE_ATTRIBUTE_ATTRIBUTES) ⇒ Object
543 544 545 546 547 548 549 |
# File 'lib/etna/clients/magma/models.rb', line 543 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
504 505 506 |
# File 'lib/etna/clients/magma/models.rb', line 504 def attribute_group raw['attribute_group'] end |
#attribute_group=(val) ⇒ Object
508 509 510 |
# File 'lib/etna/clients/magma/models.rb', line 508 def attribute_group=(val) raw['attribute_group'] = val end |
#attribute_name ⇒ Object
427 428 429 |
# File 'lib/etna/clients/magma/models.rb', line 427 def attribute_name @raw['attribute_name'] || "" end |
#attribute_name=(val) ⇒ Object
431 432 433 |
# File 'lib/etna/clients/magma/models.rb', line 431 def attribute_name=(val) @raw['attribute_name'] = val end |
#attribute_type ⇒ Object
435 436 437 |
# File 'lib/etna/clients/magma/models.rb', line 435 def attribute_type @raw['attribute_type'] && AttributeType.new(@raw['attribute_type']) end |
#attribute_type=(val) ⇒ Object
439 440 441 442 |
# File 'lib/etna/clients/magma/models.rb', line 439 def attribute_type=(val) val = val.to_s if val @raw['attribute_type'] = val end |
#desc ⇒ Object
460 461 462 |
# File 'lib/etna/clients/magma/models.rb', line 460 def desc raw['desc'] end |
#desc=(val) ⇒ Object
464 465 466 |
# File 'lib/etna/clients/magma/models.rb', line 464 def desc=(val) @raw['desc'] = val end |
#display_name ⇒ Object
468 469 470 |
# File 'lib/etna/clients/magma/models.rb', line 468 def display_name raw['display_name'] end |
#display_name=(val) ⇒ Object
472 473 474 |
# File 'lib/etna/clients/magma/models.rb', line 472 def display_name=(val) raw['display_name'] = val end |
#format_hint ⇒ Object
488 489 490 |
# File 'lib/etna/clients/magma/models.rb', line 488 def format_hint raw['format_hint'] end |
#format_hint=(val) ⇒ Object
492 493 494 |
# File 'lib/etna/clients/magma/models.rb', line 492 def format_hint=(val) raw['format_hint'] = val end |
#hidden ⇒ Object
512 513 514 |
# File 'lib/etna/clients/magma/models.rb', line 512 def hidden raw['hidden'] end |
#hidden=(val) ⇒ Object
516 517 518 |
# File 'lib/etna/clients/magma/models.rb', line 516 def hidden=(val) raw['hidden'] = val end |
#link_model_name ⇒ Object
444 445 446 |
# File 'lib/etna/clients/magma/models.rb', line 444 def link_model_name @raw['link_model_name'] end |
#link_model_name=(val) ⇒ Object
448 449 450 |
# File 'lib/etna/clients/magma/models.rb', line 448 def link_model_name=(val) @raw['link_model_name'] = val end |
#match ⇒ Object
476 477 478 |
# File 'lib/etna/clients/magma/models.rb', line 476 def match raw['match'] end |
#name ⇒ Object
419 420 421 |
# File 'lib/etna/clients/magma/models.rb', line 419 def name @raw['name'] || "" end |
#name=(val) ⇒ Object
423 424 425 |
# File 'lib/etna/clients/magma/models.rb', line 423 def name=(val) @raw['name'] = val end |
#options ⇒ Object
528 529 530 |
# File 'lib/etna/clients/magma/models.rb', line 528 def raw['options'] end |
#read_only ⇒ Object
496 497 498 |
# File 'lib/etna/clients/magma/models.rb', line 496 def read_only raw['read_only'] end |
#read_only=(val) ⇒ Object
500 501 502 |
# File 'lib/etna/clients/magma/models.rb', line 500 def read_only=(val) raw['read_only'] = val end |
#restricted ⇒ Object
480 481 482 |
# File 'lib/etna/clients/magma/models.rb', line 480 def restricted raw['restricted'] end |
#restricted=(val) ⇒ Object
484 485 486 |
# File 'lib/etna/clients/magma/models.rb', line 484 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.
410 411 412 413 414 415 416 417 |
# File 'lib/etna/clients/magma/models.rb', line 410 def set_field_defaults! @raw.replace({ 'hidden' => false, 'read_only' => false, 'restricted' => false, 'validation' => nil, }.merge(@raw)) end |
#unique ⇒ Object
452 453 454 |
# File 'lib/etna/clients/magma/models.rb', line 452 def unique raw['unique'] end |
#unique=(val) ⇒ Object
456 457 458 |
# File 'lib/etna/clients/magma/models.rb', line 456 def unique=(val) raw['unique'] = val end |
#validation ⇒ Object
520 521 522 |
# File 'lib/etna/clients/magma/models.rb', line 520 def validation raw['validation'] end |
#validation=(val) ⇒ Object
524 525 526 |
# File 'lib/etna/clients/magma/models.rb', line 524 def validation=(val) raw['validation'] = val end |