Class: CaRuby::Database::Operation
- Inherits:
-
Object
- Object
- CaRuby::Database::Operation
- Defined in:
- lib/caruby/database/operation.rb
Overview
Database CRUD operation.
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#autogenerated? ⇒ Boolean
Whether this operation is an update of an auto-generated subject.
-
#initialize(type, subject, opts = nil) ⇒ Operation
constructor
A new instance of Operation.
-
#save? ⇒ Boolean
Whether this is a create or update.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(type, subject, opts = nil) ⇒ Operation
Returns a new instance of Operation.
12 13 14 15 16 17 |
# File 'lib/caruby/database/operation.rb', line 12 def initialize(type, subject, opts=nil) @type = type @subject = subject @attribute = Options.get(:attribute, opts) @autogenerated = Options.get(:autogenerated, opts, false) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/caruby/database/operation.rb', line 5 def attribute @attribute end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/caruby/database/operation.rb', line 5 def subject @subject end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/caruby/database/operation.rb', line 5 def type @type end |
Instance Method Details
#autogenerated? ⇒ Boolean
Returns whether this operation is an update of an auto-generated subject.
25 26 27 |
# File 'lib/caruby/database/operation.rb', line 25 def autogenerated? @autogenerated end |
#save? ⇒ Boolean
Returns whether this is a create or update.
20 21 22 |
# File 'lib/caruby/database/operation.rb', line 20 def save? @type == :create or @type == :update end |
#to_s ⇒ Object Also known as: inspect
29 30 31 |
# File 'lib/caruby/database/operation.rb', line 29 def to_s "#{@subject.qp} #{attribute} #{type}" end |