Skip to content

private method `define_method' #5

@rafayet-monon

Description

@rafayet-monon

NoMethodError: private method `define_method' called for OneSignal::Notification::Headings:Class

error showing when I call

OneSignal::Notification::Headings.new(en: 'Hello!', it: 'Ciao!')

doing this in OneSignnal::Automap fixes it, is this the right way?

def create_readers **attributes
      attributes.keys.each do |k|
        self.class.send(:define_method, k) do
          attributes[k]
        end
    end
end

Also in response

NoMethodError: private method `attr_reader' called for OneSignal::Responses::Notification:Class

usinng the mattr_reader instead attr_reader fixes it in OneSignal::Responses::BaseResponse. is this the right way?

def initialize attributes = {}
        @attributes = attributes.deep_symbolize_keys
                                .keep_if { |k, _v| self.class::ATTRIBUTES_WHITELIST.include?(k.to_sym) }
        self.class.mattr_reader(*self.class::ATTRIBUTES_WHITELIST)
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions