Module: Localwiki

Defined in:
lib/localwiki/client.rb,
lib/localwiki/version.rb,
lib/localwiki/resource.rb

Defined Under Namespace

Classes: Client, File, Map, Page, PageTags, Resource, Site, Tag, User

Constant Summary collapse

VERSION =
'0.3.1'

Class Method Summary collapse

Class Method Details

.make_one(type, json_hash) ⇒ Object

create instance (of correct type) for resource

Parameters:

  • type

    resource type “site”, “page”, “user”, “file”, “map”, “tag”, “page_tags”

  • json_hash (Hash)

    hash object from parsed json

Returns:

  • new instance - child class of Localwiki::Resource



10
11
12
13
# File 'lib/localwiki/resource.rb', line 10

def self.make_one(type, json_hash)
  klass_name = type.to_s.split('_').map {|s|s.capitalize}.join
  Object.const_get('Localwiki').const_get(klass_name).new(json_hash)
end