Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private method `define_method' #5

Open
rafayet-monon opened this issue Jul 7, 2019 · 1 comment
Open

private method `define_method' #5

rafayet-monon opened this issue Jul 7, 2019 · 1 comment

Comments

@rafayet-monon
Copy link

rafayet-monon commented Jul 7, 2019

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
@uanka
Copy link

uanka commented Apr 30, 2020

hi, I've got this issue

NoMethodError: private method `define_method' called for OneSignal::Notification::Headings:Class
Did you mean?  redefine_method
from .../gems/onesignal-ruby-0.3.0/lib/onesignal/auto_map.rb:7:in `block in create_readers'

as @rafayet-monon has described above

are there any workarounds rn to send notifications with current gem version?
or when we should expect to have new version with fixed methods?

(I was following readme to send notification)
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants