Class: Knish::Member

Inherits:
Struct
  • Object
show all
Defined in:
lib/knish/member.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collection_configObject

Returns the value of attribute collection_config

Returns:

  • (Object)

    the current value of collection_config



2
3
4
# File 'lib/knish/member.rb', line 2

def collection_config
  @collection_config
end

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



2
3
4
# File 'lib/knish/member.rb', line 2

def config
  @config
end

Instance Method Details

#class_nameObject



15
16
17
# File 'lib/knish/member.rb', line 15

def class_name
  data[config.type_key]
end

#dataObject



23
24
25
# File 'lib/knish/member.rb', line 23

def data
  @data ||= reader.get_json
end

#loaded_modelObject



10
11
12
13
# File 'lib/knish/member.rb', line 10

def loaded_model
  model.load
  model
end

#modelObject



3
4
5
6
7
8
# File 'lib/knish/member.rb', line 3

def model
  return @model if @model
  @model = model_class.new(id: config.id)
  @model.config = collection_config.member_config(@model.config, config.id)
  @model
end

#model_classObject



19
20
21
# File 'lib/knish/member.rb', line 19

def model_class
  class_name && eval(class_name)
end

#readerObject



27
28
29
# File 'lib/knish/member.rb', line 27

def reader
  Reader.new(config)
end