Class: HookBridge::BaseModel
- Inherits:
-
Object
- Object
- HookBridge::BaseModel
- Defined in:
- lib/hookbridge/types.rb
Direct Known Subclasses
APIKey, APIKeyCreated, AckPullEventsResponse, AttemptRecord, CheckoutSession, CreateEndpointResponse, CreateInboundEndpointResponse, DLQMessage, DeleteBatchItemResult, DeleteEventBatchItemResult, DeleteEventResult, DeleteMessageResult, DeletePartialError, DeleteResult, Endpoint, EndpointSummary, ExportRecord, InboundEndpoint, InboundEndpointSummary, InboundLogEntry, InboundMessage, InboundMetrics, InboundRejection, Invoice, InvoiceLine, ListenMessage, Message, MessageSummary, Metrics, PauseState, PortalSession, Project, PullEndpoint, PullEndpointCounts, PullEndpointSummary, PullEventDetail, PullEventSummary, PullLogEntry, PullTimeSeriesBucket, PullTimingBreakdown, ReplayAllMessagesResponse, ReplayBatchResult, ReplayResponse, RotateSecretResponse, SendResponse, SigningKey, SubscriptionLimits, SubscriptionUsage, TimeSeriesBucket, UpdateResult, UsageHistoryRow
Instance Method Summary collapse
-
#initialize(data = {}, time_fields: [], date_fields: []) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data = {}, time_fields: [], date_fields: []) ⇒ BaseModel
Returns a new instance of BaseModel.
41 42 43 44 45 46 |
# File 'lib/hookbridge/types.rb', line 41 def initialize(data = {}, time_fields: [], date_fields: []) @attributes = {} (data || {}).each do |key, value| @attributes[key.to_s] = convert_value(key.to_s, value, time_fields, date_fields) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/hookbridge/types.rb', line 52 def method_missing(name, *args, &block) return super unless args.empty? && block.nil? key = name.to_s return @attributes[key] if @attributes.key?(key) super end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
61 62 63 |
# File 'lib/hookbridge/types.rb', line 61 def respond_to_missing?(name, include_private = false) @attributes.key?(name.to_s) || super end |
#to_h ⇒ Object
48 49 50 |
# File 'lib/hookbridge/types.rb', line 48 def to_h @attributes.transform_keys(&:to_sym) end |