Class: EasyAttributes::Config
- Inherits:
-
Object
- Object
- EasyAttributes::Config
- Defined in:
- lib/easy_attributes.rb
Overview
EasyAttributes::Config - Namespace to define and hold configuration data.
Class Method Summary collapse
- .constantize ⇒ Object
-
.constantize=(b) ⇒ Object
Directive to create constants from field value names: FIELD_NAME_VALUE_NAME=value.
-
.enum_start ⇒ Object
Starting point for enum sequences (usually 0 or 1).
- .enum_start=(n) ⇒ Object
-
.kb_size ⇒ Object
Public: Returns the current kb_size setting for use in computing Bytes.
-
.kb_size=(setting) ⇒ Object
Public: Set the default size for a kilobyte/kibibyte Refer to: en.wikipedia.org/wiki/Binary_prefix.
-
.orm ⇒ Object
Public: Returns the current ORM setting.
-
.orm=(new_orm) ⇒ Object
Public: Sets the ORM (Object Relational Mapper) to a supported policy.
Class Method Details
.constantize ⇒ Object
536 537 538 |
# File 'lib/easy_attributes.rb', line 536 def self.constantize @constantize || false end |
.constantize=(b) ⇒ Object
Directive to create constants from field value names: FIELD_NAME_VALUE_NAME=value
532 533 534 |
# File 'lib/easy_attributes.rb', line 532 def self.constantize=(b) @constantize = b ? true : false end |
.enum_start ⇒ Object
Starting point for enum sequences (usually 0 or 1)
541 542 543 |
# File 'lib/easy_attributes.rb', line 541 def self.enum_start @enum_start || 1 end |
.enum_start=(n) ⇒ Object
545 546 547 |
# File 'lib/easy_attributes.rb', line 545 def self.enum_start=(n) @enum_start = n end |
.kb_size ⇒ Object
Public: Returns the current kb_size setting for use in computing Bytes
Returns the current kb_size setting
500 501 502 503 504 505 506 507 508 509 |
# File 'lib/easy_attributes.rb', line 500 def self.kb_size case @kb_size when :new, :iec then 1024 when :old, :jedec, :decimal 1000 else @kb_size end end |
.kb_size=(setting) ⇒ Object
Public: Set the default size for a kilobyte/kibibyte
Refer to: http://en.wikipedia.org/wiki/Binary_prefix
setting - How to represent kilobyte
:new, :iec uses KiB=1024, no KB
:old, :jedec, or 1024 uses KB=1024
1000, :decimal uses only KB (1000) (other values mix KB and KiB units)
Note: "IEC" is the International Electrotechnical Commission
"JEDEC" is the Joint Electron Devices Engineering Council
Examples
EasyAttributes::Config.kb_size = :iec
Returns new setting
492 493 494 |
# File 'lib/easy_attributes.rb', line 492 def self.kb_size=(setting) @kb_size = setting end |
.orm ⇒ Object
Public: Returns the current ORM setting
Returns the current ORM setting
527 528 529 |
# File 'lib/easy_attributes.rb', line 527 def self.orm @orm end |
.orm=(new_orm) ⇒ Object
Public: Sets the ORM (Object Relational Mapper) to a supported policy
new_orm - value
:attr = attr_accessor style operations
:acitve_model = Rails ActiveModel operations
Returns the new ORM setting
519 520 521 |
# File 'lib/easy_attributes.rb', line 519 def self.orm=(new_orm) @orm = new_orm end |