Class: JSONAPIonify::Types::StringType::StringSampler

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapionify/types/string_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(field_name) ⇒ StringSampler

Returns a new instance of StringSampler.



26
27
28
# File 'lib/jsonapionify/types/string_type.rb', line 26

def initialize(field_name)
  @field_name = field_name
end

Instance Method Details

#descriptionObject Also known as: body, content, prompt



42
43
44
# File 'lib/jsonapionify/types/string_type.rb', line 42

def description
  Faker::Lorem.paragraph
end

#domainObject



38
39
40
# File 'lib/jsonapionify/types/string_type.rb', line 38

def domain
  [Faker::Internet.domain_word, Faker::Internet.domain_suffix].join '.'
end

#full_nameObject



34
35
36
# File 'lib/jsonapionify/types/string_type.rb', line 34

def full_name
  Faker::Name.name
end

#hacker_speakObject



30
31
32
# File 'lib/jsonapionify/types/string_type.rb', line 30

def hacker_speak
  Faker::Hacker.say_something_smart
end

#valueObject



50
51
52
53
54
55
56
57
58
# File 'lib/jsonapionify/types/string_type.rb', line 50

def value
  if self.class.instance_methods(false).include?(@field_name)
    public_send(@field_name)
  elsif (field = self.class.instance_methods(false).find { |m| @field_name.to_s.include? m.to_s })
    public_send(field)
  else
    Faker::Lorem.word
  end
end