Class: NextErpBridge::Entity::Base
- Inherits:
-
Object
- Object
- NextErpBridge::Entity::Base
- Includes:
- Core::Entry
- Defined in:
- lib/next_erp_bridge/entity/base.rb
Constant Summary collapse
- @@klass_registry =
{ }
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Base
constructor
A new instance of Base.
- #method_missing(m, *args, &block) ⇒ Object
Methods included from Core::Entry
Constructor Details
#initialize(attributes) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/next_erp_bridge/entity/base.rb', line 9 def initialize(attributes) @attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/next_erp_bridge/entity/base.rb', line 13 def method_missing(m, *args, &block) keys = attributes.keys.map(&:to_s) m = m.to_s is_setter = (m[-1] == '=') if is_setter m = m[0..(m.size-2)] end if keys.include?(m) attributes[m] = args[0] if is_setter attributes[m] else super(m.to_sym, *args) end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/next_erp_bridge/entity/base.rb', line 7 def attributes @attributes end |
Class Method Details
.klass_registry ⇒ Object
28 29 30 |
# File 'lib/next_erp_bridge/entity/base.rb', line 28 def self.klass_registry @@klass_registry end |