Class: Bonita::BaseModel
- Inherits:
-
Object
- Object
- Bonita::BaseModel
- Defined in:
- lib/bonita/models/base_model.rb
Direct Known Subclasses
Bonita::Bpm::Process, Customuserinfo::Definition, Customuserinfo::User, Customuserinfo::Value, Identity::Group, Identity::Membership, Identity::Role, Identity::User
Class Attribute Summary collapse
-
.attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #inspect ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ BaseModel
Returns a new instance of BaseModel.
18 19 20 21 22 |
# File 'lib/bonita/models/base_model.rb', line 18 def initialize(params = {}) self.class.attributes.each do |key| instance_variable_set("@#{key}", params[key]) end end |
Class Attribute Details
.attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/bonita/models/base_model.rb', line 6 def attributes @attributes end |
Class Method Details
.attribute(name) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/bonita/models/base_model.rb', line 8 def attribute(name) @attributes ||= [] return if @attributes.include? name @attributes << name send(:attr_accessor, name) end |
Instance Method Details
#inspect ⇒ Object
24 25 26 27 |
# File 'lib/bonita/models/base_model.rb', line 24 def inspect values = Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }] "<#{self.class.name} #{values}>" end |