Class: SupportOps::Slack::Base
- Inherits:
-
Object
- Object
- SupportOps::Slack::Base
- Defined in:
- lib/support_ops_slack/slack/base.rb
Overview
Defines the class Base within the module SupportOps::Slack.
Direct Known Subclasses
Class Method Summary collapse
- .attributes ⇒ Object
- .client ⇒ Object
- .configure {|Configuration.config| ... } ⇒ Object
- .define_attributes(*attrs) ⇒ Object
- .readonly_attributes(*attrs) ⇒ Object
Instance Method Summary collapse
- #client=(new_client) ⇒ Object
-
#initialize(attributes = {}, client = nil) ⇒ Base
constructor
A new instance of Base.
- #save! ⇒ Object
- #store_original_attributes ⇒ Object
Constructor Details
#initialize(attributes = {}, client = nil) ⇒ Base
Returns a new instance of Base.
40 41 42 43 44 45 |
# File 'lib/support_ops_slack/slack/base.rb', line 40 def initialize(attributes = {}, client = nil) @client = client @original_attributes = {} set_attributes(attributes) store_original_attributes end |
Class Method Details
.attributes ⇒ Object
29 30 31 |
# File 'lib/support_ops_slack/slack/base.rb', line 29 def attributes @attributes || [] end |
.client ⇒ Object
14 15 16 |
# File 'lib/support_ops_slack/slack/base.rb', line 14 def client Configuration.config.client end |
.configure {|Configuration.config| ... } ⇒ Object
18 19 20 |
# File 'lib/support_ops_slack/slack/base.rb', line 18 def configure yield Configuration.config end |
.define_attributes(*attrs) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/support_ops_slack/slack/base.rb', line 22 def define_attributes(*attrs) @attributes = attrs attrs.each do |attr| attr_accessor attr end end |
.readonly_attributes(*attrs) ⇒ Object
33 34 35 36 37 |
# File 'lib/support_ops_slack/slack/base.rb', line 33 def readonly_attributes(*attrs) return @readonly_attributes || [] if attrs.empty? @readonly_attributes = attrs end |
Instance Method Details
#client=(new_client) ⇒ Object
59 60 61 |
# File 'lib/support_ops_slack/slack/base.rb', line 59 def client=(new_client) @client = new_client end |
#save! ⇒ Object
54 55 56 57 |
# File 'lib/support_ops_slack/slack/base.rb', line 54 def save! ensure_client_present! create_record end |
#store_original_attributes ⇒ Object
47 48 49 50 51 52 |
# File 'lib/support_ops_slack/slack/base.rb', line 47 def store_original_attributes @original_attributes = {} self.class.attributes.each do |attr| @original_attributes[attr] = instance_variable_get("@#{attr}") end end |