Skip to content

Instantly share code, notes, and snippets.

@wstucco
Last active May 28, 2019 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wstucco/42392ee21b76dfa3ef83 to your computer and use it in GitHub Desktop.
Save wstucco/42392ee21b76dfa3ef83 to your computer and use it in GitHub Desktop.
Opal Meteor
if Meteor.client?
user = User.new('Admin')
puts user
puts user.admin?
puts "hello from client #{user.name}!"
end
if Meteor.server?
user = User.new('Massimo')
puts user
puts user.admin?
puts "hello from server #{user.name}!"
end
class Meteor
def self.server?
`Meteor.isServer`
end
def self.client?
`Meteor.isClient`
end
def self.cordova?
`Meteor.isCordova`
end
def self.startup(&block)
`#{block.call if block_given?}`
end
def self.wrap_async(func, context = nil)
`Meteor.wrapAsync(#{func.to_n}, #{context.to_n})` if context
`Meteor.wrapAsync(#{func.to_n})` unless context
end
end
class User
attr_accessor :name
def initialize(name)
@name = name
end
def admin?
@name == 'Admin'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment