Class: Icss::Meta::Message
- Includes:
- ReceiverModel
- Defined in:
- lib/icss/message.rb,
lib/icss/protocol.rb,
lib/icss/message/message_sample.rb
Overview
predefine so we can use below
Instance Attribute Summary collapse
-
#protocol ⇒ Object
this is defined in sample_message_call.rb – since we don’t do referenced types yet.
Instance Method Summary collapse
- #first_sample_request_param ⇒ Object
- #fullname ⇒ Object
- #geolocators ⇒ Object
-
#is_a_geo? ⇒ Boolean
—————————————- GEO.
-
#params_type ⇒ Object
the type of the message’s params (by convention, its first request field).
- #path ⇒ Object
- #receive_is_geo(val) ⇒ Object
-
#to_hash ⇒ Object
Conversion.
- #to_json(*args) ⇒ Object
Methods included from ReceiverModel
Methods included from ReceiverModel::ActsAsTuple
Methods included from RecordModel
#attr_set?, included, #receive!, #to_zaml
Methods included from ReceiverModel::ActsAsLoadable
Methods included from ReceiverModel::ActsAsHash
#[], #[]=, #attributes, #delete, included, #keys
Instance Attribute Details
#protocol ⇒ Object
this is defined in sample_message_call.rb – since we don’t do referenced types yet
33 34 35 |
# File 'lib/icss/message.rb', line 33 def protocol @protocol end |
Instance Method Details
#first_sample_request_param ⇒ Object
61 62 63 64 |
# File 'lib/icss/message.rb', line 61 def first_sample_request_param req = samples.first.request.first rescue nil req || {} end |
#fullname ⇒ Object
49 50 51 |
# File 'lib/icss/message.rb', line 49 def fullname "#{protocol.fullname}.#{basename}" end |
#geolocators ⇒ Object
92 93 94 |
# File 'lib/icss/message.rb', line 92 def geolocators request_decorators[:anchors] end |
#is_a_geo? ⇒ Boolean
GEO
70 71 72 |
# File 'lib/icss/message.rb', line 70 def is_a_geo? geolocators.present? end |
#params_type ⇒ Object
the type of the message’s params (by convention, its first request field)
57 58 59 |
# File 'lib/icss/message.rb', line 57 def params_type request.first ? request.first.type : {} end |
#path ⇒ Object
52 53 54 |
# File 'lib/icss/message.rb', line 52 def path fullname.gsub(%r{\.},'/') end |
#receive_is_geo(val) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/icss/message.rb', line 75 def receive_is_geo(val) return unless val unless defined?(Icss::Meta::Req::Geolocator) then warn "View helpers can\'t help with geolocators: Icss::Meta::Req::Geolocator type is missing. Is the catalog loaded properly?" return end self.request_decorators = { :anchors => [ Icss::Meta::Req::PointWithRadiusGeolocator, Icss::Meta::Req::AddressTextGeolocator, Icss::Meta::Req::TileXYZoomGeolocator, Icss::Meta::Req::BoundingBoxGeolocator, Icss::Meta::Req::IpAddressGeolocator ], } end |
#to_hash ⇒ Object
Conversion
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/icss/message.rb', line 99 def to_hash() { :request => summary_of_request_attr, :response => summary_of_response_attr, :doc => doc, :errors => (errors.blank? ? nil : errors), :samples => samples.map(&:to_hash).map(&:compact_blank), :initial_free_qty => initial_free_qty, :price_per_k_in_cents => price_per_k_in_cents, }.compact end |
#to_json(*args) ⇒ Object
110 |
# File 'lib/icss/message.rb', line 110 def to_json(*args) to_hash.to_json(*args) ; end |