Module: Driftrock::Service::DriftrockModel

Included in:
Admin::DriftrockModel::Company, Admin::DriftrockModel::DriftrockApp, Admin::DriftrockModel::DriftrockCompany, Admin::DriftrockModel::DriftrockUser, Channel, ChannelType, Company, CompanyInvite, DriftrockApp, User, Visitor::DriftrockModel::DriftrockApp
Defined in:
lib/driftrock-service/driftrock_model.rb,
lib/driftrock-service/driftrock_model/user.rb,
lib/driftrock-service/driftrock_model/channel.rb,
lib/driftrock-service/driftrock_model/company.rb,
lib/driftrock-service/driftrock_model/channel_type.rb,
lib/driftrock-service/driftrock_model/driftrock_app.rb,
lib/driftrock-service/driftrock_model/company_invite.rb

Defined Under Namespace

Modules: ActiveRecordSimulator, ClassMethods, DependencyInjection Classes: Channel, ChannelType, Company, CompanyInvite, DriftrockApp, User

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/driftrock-service/driftrock_model.rb', line 99

def self.included(base)
  base.extend DependencyInjection
  base.extend ActiveRecordSimulator
  base.extend ClassMethods
  base.extend Driftrock::Service::Api
  base.send(:include, Driftrock::Service::Api)
end

Instance Method Details

#get_from_api_methodObject



107
108
109
# File 'lib/driftrock-service/driftrock_model.rb', line 107

def get_from_api_method
  self.class.get_from_api_method
end

#initialize(object_hash) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/driftrock-service/driftrock_model.rb', line 85

def initialize(object_hash)
  if object_hash.respond_to?(:symbolize_keys!)
    object_hash.symbolize_keys!
  else
    symbolise_keys(object_hash)
  end
  object_hash.each do |(key, value)|
    instance_variable_set(("@"+key.to_s).to_sym, value)
    instance_var_reader = lambda { instance_variable_get("@" + key.to_s) }
    self.class.send(:define_method, key.to_s, instance_var_reader)
  end
end

#post_to_api_methodObject



111
112
113
# File 'lib/driftrock-service/driftrock_model.rb', line 111

def post_to_api_method
  self.class.post_to_api_method
end

#put_to_api_methodObject



115
116
117
# File 'lib/driftrock-service/driftrock_model.rb', line 115

def put_to_api_method
  self.class.put_to_api_method
end