Class: Esputnik::Channel

Inherits:
Struct
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/esputnik/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deviceObject

Returns the value of attribute device

Returns:

  • (Object)

    the current value of device



4
5
6
# File 'lib/esputnik/channel.rb', line 4

def device
  @device
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/esputnik/channel.rb', line 4

def type
  @type
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/esputnik/channel.rb', line 4

def value
  @value
end

#web_push_subscriptionObject

Returns the value of attribute web_push_subscription

Returns:

  • (Object)

    the current value of web_push_subscription



4
5
6
# File 'lib/esputnik/channel.rb', line 4

def web_push_subscription
  @web_push_subscription
end

Instance Method Details

#as_jsonObject



13
14
15
16
17
18
19
# File 'lib/esputnik/channel.rb', line 13

def as_json
  self.class.members.each_with_object({}) do |method_name, h|
    value = public_send(method_name)
    value = value.as_json if value.respond_to? :as_json
    h[method_name.to_s.camelize(:lower)] = value if value.present?
  end
end